Skip to content

Commit

Permalink
Compilation: check for embedded null bytes in path for has_include
Browse files Browse the repository at this point in the history
  • Loading branch information
ehaas authored and Vexu committed Nov 28, 2023
1 parent efed229 commit 070f3ba
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.zig text eol=lf
test/cases/expanded/* text eol=lf
test/cases/ast/* text eol=lf
test/cases/__has_include.c text diff eol=lf

deps/** linguist-vendored
test/records/** linguist-generated=true
Expand Down
4 changes: 4 additions & 0 deletions src/aro/Compilation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,10 @@ pub fn hasInclude(
/// __has_include vs __has_include_next
which: WhichInclude,
) !bool {
if (mem.indexOfScalar(u8, filename, 0) != null) {
return false;
}

const cwd = std.fs.cwd();
if (std.fs.path.isAbsolute(filename)) {
if (which == .next) return false;
Expand Down
Binary file modified test/cases/__has_include.c
Binary file not shown.

0 comments on commit 070f3ba

Please sign in to comment.