]> ruderich.org/simon Gitweb - blhc/blhc.git/blobdiff - bin/blhc
Fix architecture detection when checking multiple files.
[blhc/blhc.git] / bin / blhc
index 028dfbe53190d67f1a70768098fba0c3bfb33531..eb803248d784514aff2143a3c4835d475daa25db 100755 (executable)
--- a/bin/blhc
+++ b/bin/blhc
@@ -475,6 +475,9 @@ my $exit = 0;
 FILE: foreach my $file (@ARGV) {
     open my $fh, '<', $file or die "$!: $file";
 
+    # Architecture of this file.
+    my $arch = $option_arch;
+
     # Hardening options. Not all architectures support all hardening options.
     my $harden_format  = 1;
     my $harden_fortify = 1;
@@ -549,9 +552,9 @@ FILE: foreach my $file (@ARGV) {
         last if $line =~ /^Build finished at \d{8}-\d{4}$/;
 
         # Detect architecture automatically unless overridden.
-        if (not $option_arch
+        if (not $arch
                 and $line =~ /^dpkg-buildpackage: host architecture (.+)$/) {
-            $option_arch = $1;
+            $arch = $1;
         }
 
         # Ignore compiler warnings for now.
@@ -655,7 +658,7 @@ FILE: foreach my $file (@ARGV) {
     }
 
     # Option or auto detected.
-    if ($option_arch) {
+    if ($arch) {
         # The following was partially copied from dpkg-dev 1.16.1.2
         # (/usr/share/perl5/Dpkg/Vendor/Debian.pm, add_hardening_flags()),
         # copyright RaphaĆ«l Hertzog <hertzog@debian.org>, Kees Cook
@@ -663,10 +666,10 @@ FILE: foreach my $file (@ARGV) {
         # later. Keep it in sync.
 
         require Dpkg::Arch;
-        my ($abi, $os, $cpu) = Dpkg::Arch::debarch_to_debtriplet($option_arch);
+        my ($abi, $os, $cpu) = Dpkg::Arch::debarch_to_debtriplet($arch);
 
         # Disable unsupported hardening options.
-        if ($cpu =~ /^(ia64|alpha|mips|mipsel|hppa)$/ or $option_arch eq 'arm') {
+        if ($cpu =~ /^(ia64|alpha|mips|mipsel|hppa)$/ or $arch eq 'arm') {
             $harden_stack = 0;
         }
         if ($cpu =~ /^(ia64|hppa|avr32)$/) {