From 5dd19bb96effb0b40c26bb669dd0f8ef176ebf40 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Mon, 14 Sep 2015 18:10:44 +0200 Subject: [PATCH] fix false positive in "libtool: link: g++ -include test.h .." MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The .h extension causes detection as preprocess line which generates a warning about missing CPPFLAGS. Fix this false positive for the "libtool: link:" case. As long as GNU autotools generate sane output, this should not cause false negatives. Fixes Debian Bug #784959 reported by Raphaël Hertzog. --- NEWS | 2 ++ bin/blhc | 9 ++++++++- t/logs/libtool | 5 ++--- t/tests.t | 6 +----- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index 9245c13..a3dffc8 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,8 @@ Version 0.XX ------------ - Sync architecture specific hardening support with dpkg 1.18.2. +- Fix false positive in "libtool: link: g++ -include test.h .." (Debian Bug + #784959), reported by Raphaël Hertzog. Version 0.05 diff --git a/bin/blhc b/bin/blhc index 7d74902..0c2ba90 100755 --- a/bin/blhc +++ b/bin/blhc @@ -51,6 +51,7 @@ my $warning_regex = qr/^(.+?):(\d+):\d+: warning: (.+?) \[(.+?)\]$/; # Regex to catch libtool commands and not lines which show commands executed # by libtool (e.g. libtool: link: ...). my $libtool_regex = qr/\blibtool\s.*--mode=/; +my $libtool_link_regex = qr/\blibtool: link: /; # List of source file extensions which require preprocessing. my @source_preprocess_compile_cpp = ( @@ -1101,6 +1102,8 @@ LINE: # is_non_verbose_build()). next if $skip; + my $orig_line = $line; + # Remove everything until and including the compiler command. Makes # checks easier and faster. $line =~ s/^.*?$cc_regex//o; @@ -1151,7 +1154,11 @@ LINE: } # These file types require preprocessing. if (extension_found(\%extensions_preprocess, @extensions)) { - $preprocess = 1; + # Prevent false positives with "libtool: link: g++ -include test.h + # .." compiler lines. + if ($orig_line !~ /$libtool_link_regex/o) { + $preprocess = 1; + } } if (not $flag_preprocess) { diff --git a/t/logs/libtool b/t/logs/libtool index 89ca758..aec9602 100644 --- a/t/logs/libtool +++ b/t/logs/libtool @@ -38,9 +38,8 @@ libtool: link: gcc -Wl,-z,relro -o test.so test.o libtool: link: gcc -g -O2 -fstack-protector-strong -Wformat -Wformat-security -Werror=format-security -Wl,-z,relro -o test test.o gcc -g -O2 -fstack-protector-strong -Wformat -Wformat-security -Werror=format-security -Wl,-z -Wl,relro -o .libs/test test.o -# Just to be sure, libtool won't do this. Note the test.c. -/bin/bash ../libtool --tag=CC --mode=link gcc -Wl,-z,relro -o test.so test.c -libtool: link: gcc -Wl,-z,relro -o test.so test.c +# Note the .h, this might cause a false positive CPPFLAGS check. +libtool: link: g++ -include ./include/CppUTest/MemoryLeakDetectorNewMacros.h -Wall -Wextra -Wshadow -Wswitch-default -Wswitch-enum -Wconversion -pedantic -Wsign-conversion -Woverloaded-virtual -Wno-disabled-macro-expansion -Wno-padded -Wno-global-constructors -Wno-exit-time-destructors -Wno-weak-vtables -Wno-old-style-cast -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z -Wl,relro -o CppUTestTests CppUTestTests-AllocationInCFile.o CppUTestTests-AllocationInCppFile.o CppUTestTests-AllocLetTestFree.o CppUTestTests-AllocLetTestFreeTest.o CppUTestTests-AllTests.o CppUTestTests-CheatSheetTest.o CppUTestTests-CommandLineArgumentsTest.o CppUTestTests-CommandLineTestRunnerTest.o CppUTestTests-JUnitOutputTest.o CppUTestTests-MemoryLeakDetectorTest.o CppUTestTests-MemoryLeakOperatorOverloadsTest.o CppUTestTests-MemoryLeakWarningTest.o CppUTestTests-PluginTest.o CppUTestTests-PreprocessorTest.o CppUTestTests-SetPluginTest.o CppUTest Tests-SimpleStringTest.o CppUTestTests-SimpleMutexTest.o CppUTestTests-TestFailureNaNTest.o CppUTestTests-TestFailureTest.o CppUTestTests-TestFilterTest.o CppUTestTests-TestHarness_cTest.o CppUTestTests-TestHarness_cTestCFile.o CppUTestTests-TestInstallerTest.o CppUTestTests-TestMemoryAllocatorTest.o CppUTestTests-TestOutputTest.o CppUTestTests-TestRegistryTest.o CppUTestTests-TestResultTest.o CppUTestTests-TestUTestMacro.o CppUTestTests-UtestTest.o CppUTestTests-UtestPlatformTest.o lib/libCppUTest.a -lpthread libtool: install: /usr/bin/install -c ... /bin/bash ./libtool --mode=install /usr/bin/install -c ... diff --git a/t/tests.t b/t/tests.t index 939aaf9..9fa6fc3 100644 --- a/t/tests.t +++ b/t/tests.t @@ -796,12 +796,8 @@ LDFLAGS missing (-fPIE -pie -Wl,-z,now): libtool: relink: gcc -Wl,-z,relro -o t LDFLAGS missing (-fPIE -pie -Wl,-z,now): libtool: relink: g++ -Wl,-z,relro -o test.la test.o LDFLAGS missing (-fPIE -pie -Wl,-z,now): libtool: link: gcc -g -O2 -fstack-protector-strong -Wformat -Wformat-security -Werror=format-security -Wl,-z,relro -o test test.o LDFLAGS missing (-fPIE -pie -Wl,-z,now): gcc -g -O2 -fstack-protector-strong -Wformat -Wformat-security -Werror=format-security -Wl,-z -Wl,relro -o .libs/test test.o -CFLAGS missing (-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security): libtool: link: gcc -Wl,-z,relro -o test.so test.c -CPPFLAGS missing (-D_FORTIFY_SOURCE=2): libtool: link: gcc -Wl,-z,relro -o test.so test.c -LDFLAGS missing (-fPIE -pie -Wl,-z,now): libtool: link: gcc -Wl,-z,relro -o test.so test.c -CPPFLAGS missing (-D_FORTIFY_SOURCE=2): libtool: link: gcc -Wl,-z,relro -o libtest.la test.h test-a.lo test-b.lo test-c.lo test-d.la +LDFLAGS missing (-fPIE -pie -Wl,-z,now): libtool: link: g++ -include ./include/CppUTest/MemoryLeakDetectorNewMacros.h -Wall -Wextra -Wshadow -Wswitch-default -Wswitch-enum -Wconversion -pedantic -Wsign-conversion -Woverloaded-virtual -Wno-disabled-macro-expansion -Wno-padded -Wno-global-constructors -Wno-exit-time-destructors -Wno-weak-vtables -Wno-old-style-cast -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z -Wl,relro -o CppUTestTests CppUTestTests-AllocationInCFile.o CppUTestTests-AllocationInCppFile.o CppUTestTests-AllocLetTestFree.o CppUTestTests-AllocLetTestFreeTest.o CppUTestTests-AllTests.o CppUTestTests-CheatSheetTest.o CppUTestTests-CommandLineArgumentsTest.o CppUTestTests-CommandLineTestRunnerTest.o CppUTestTests-JUnitOutputTest.o CppUTestTests-MemoryLeakDetectorTest.o CppUTestTests-MemoryLeakOperatorOverloadsTest.o CppUTestTests-MemoryLeakWarningTest.o CppUTestTests-PluginTest.o CppUTestTests-PreprocessorTest.o CppUTestTests-SetPluginTest.o CppUTest Tests-SimpleStringTest.o CppUTestTests-SimpleMutexTest.o CppUTestTests-TestFailureNaNTest.o CppUTestTests-TestFailureTest.o CppUTestTests-TestFilterTest.o CppUTestTests-TestHarness_cTest.o CppUTestTests-TestHarness_cTestCFile.o CppUTestTests-TestInstallerTest.o CppUTestTests-TestMemoryAllocatorTest.o CppUTestTests-TestOutputTest.o CppUTestTests-TestRegistryTest.o CppUTestTests-TestResultTest.o CppUTestTests-TestUTestMacro.o CppUTestTests-UtestTest.o CppUTestTests-UtestPlatformTest.o lib/libCppUTest.a -lpthread LDFLAGS missing (-fPIE -pie -Wl,-z,now): libtool: link: gcc -Wl,-z,relro -o libtest.la test.h test-a.lo test-b.lo test-c.lo test-d.la -CPPFLAGS missing (-D_FORTIFY_SOURCE=2): libtool: link: gcc -o libtest.la test.h test-a.lo test-b.lo test-c.lo test-d.la LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): libtool: link: gcc -o libtest.la test.h test-a.lo test-b.lo test-c.lo test-d.la NONVERBOSE BUILD: /usr/share/apr-1.0/build/libtool --silent --mode=compile x86_64-linux-gnu-gcc -std=gnu99 -I/usr/include/libxml2 -pthread -pipe -g -O2 -fstack-protector-strong -Wformat -Werror=format-security ... -prefer-pic -c mod_buffer.c NONVERBOSE BUILD: /usr/share/apr-1.0/build/libtool --silent --mode=link x86_64-linux-gnu-gcc -std=gnu99 -I/usr/include/libxml2 -pthread -pipe -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wl,--as-needed -Wl,-z,relro -o mod_buffer.la -rpath /usr/lib/apache2/modules -module -avoid-version mod_buffer.lo -- 2.45.2