From 070f3baef7b5c1736efa58bc5807073cf9aa5e42 Mon Sep 17 00:00:00 2001 From: Evan Haas <evan@lagerdata.com> Date: Mon, 27 Nov 2023 14:34:09 -0800 Subject: [PATCH] Compilation: check for embedded null bytes in path for has_include --- .gitattributes | 1 + src/aro/Compilation.zig | 4 ++++ test/cases/__has_include.c | Bin 1938 -> 2039 bytes 3 files changed, 5 insertions(+) diff --git a/.gitattributes b/.gitattributes index 7fe517fb..fa202179 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/src/aro/Compilation.zig b/src/aro/Compilation.zig index a5bc6458..38020067 100644 --- a/src/aro/Compilation.zig +++ b/src/aro/Compilation.zig @@ -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; diff --git a/test/cases/__has_include.c b/test/cases/__has_include.c index 2d2de718bf9d55e41ee82e2e73a904b9ac725387..0da91517df7587eef9caa6c30c1fb5530a5cc31d 100644 GIT binary patch delta 77 zcmbQl|DAt>46B;HmO?;cNrpmFYEFK+LPlb-LTYYOYD!9Kih^ILk3v#qNveXD{^YaF h;)0oZC3+bQN}62CsYONkMGC=_&oN1EmSrtr0szPW7$^V$ delta 14 Vcmey)KZ$>X4D045)>0-$E&wOQ1T_Ev