On Sun, Nov 29, 2020 at 07:21:48PM +0100, Fabian Wolff wrote: > On 11/28/20 10:47 PM, Eriberto wrote: >> Thanks Fabian and Simon! >> >> Considering that some false positives can't be fixed in blhc source >> code, could I close this bug? > > I think it would make more sense to close this bug with the next > upstream release, given that some changes in blhc have been applied > because of it (commit 79d3a9e in the upstream repository), and it's > also mentioned in the NEWS entry for the next release.
Hello Fabian, sorry for the late reply. While looking at Olaf's report I also thought about your original report and I might have a (partial) solution. The problem in this case is only the compiler detection, not actually handling environment variables. So stripping them should be enough. I've implemented a patch which strips (basic) environment variables (no nested quotes, command substitution, etc.). Could you test the attached patch and tell me if this works for you for real builds? Regards Simon -- + Privatsphäre ist notwendig + Ich verwende GnuPG http://gnupg.org + Öffentlicher Schlüssel: 0x92FEFDB7E44C32F9
From 5cb3ea785d8c4602a703336797f42295d1980827 Mon Sep 17 00:00:00 2001 Message-Id: <5cb3ea785d8c4602a703336797f42295d1980827.1633434227.git.si...@ruderich.org> From: Simon Ruderich <[email protected]> Date: Tue, 5 Oct 2021 13:43:29 +0200 Subject: [PATCH] Strip (basic) environment variables before compiler detection --- bin/blhc | 20 +++++++++++++++++++- t/tests.t | 4 ++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/bin/blhc b/bin/blhc index 2f8da5f..d41ff88 100755 --- a/bin/blhc +++ b/bin/blhc @@ -1022,9 +1022,27 @@ foreach my $file (@ARGV) { $complete_line = undef; } + my $noenv = $line; + # Strip (basic) environment variables for compiler detection. + # Nested quotes, command substitution, etc. is not supported. + $noenv =~ s/^ + \s* + (?: + [a-zA-Z_]+ # environment variable name + = + (?: + [^\s"'\$\\]+ # non-quoted string + | + '[^"'\$`\\]*' # single-quoted string + | + "[^"'\$`\\]*" # double-quoted string + ) + \s+ + )* + //x; # Ignore lines with no compiler commands. next if not $non_verbose - and not $line =~ /$cc_regex_normal/o; + and not $noenv =~ /$cc_regex_normal/o; # Ignore lines with no filenames with extensions. May miss some # non-verbose builds (e.g. "gcc -o test" [sic!]), but shouldn't be # a problem as the log will most likely contain other non-verbose diff --git a/t/tests.t b/t/tests.t index b4c0352..737f3ec 100644 --- a/t/tests.t +++ b/t/tests.t @@ -633,8 +633,8 @@ CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -g -O2 -fstack-protector-strong -Wfo LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): gcc -g -O2 -fstack-protector-strong -Wformat -Wformat-security -Werror=format-security test.c -o lib`basename test/test`.so '; -is_blhc 'env', '--all', 8, - 'CPPFLAGS missing (-D_FORTIFY_SOURCE=2): VERSION=v-amd64-linux CPP="gcc -x assembler-with-cpp -E -P -Wdate-time -D_FORTIFY_SOURCE=2" CPPFLAGS="-Wdate-time -D_FORTIFY_SOURCE=2" ../../config/gen-posix-names.sh _SC_ ml_sysconf.h +is_blhc 'env', '--all', 1, + 'No compiler commands! '; -- 2.33.0
signature.asc
Description: PGP signature

