summaryrefslogtreecommitdiff
path: root/dh_strip
diff options
context:
space:
mode:
authorjoey <joey>2001-12-27 02:22:58 +0000
committerjoey <joey>2001-12-27 02:22:58 +0000
commita37ba2e615d3dbcaa89201d657a6a7b6790576be (patch)
tree5add95213137b64f101e5c6d033f7820fe69d2b5 /dh_strip
parent1580712ddc7c6faf97ed46452e410e72291814ce (diff)
r499: * dh_strip: run file using a safe pipe open, that will not expose any weird
characters in filenames to a shell. Closes: #126491 * fixed dh_testdir man page
Diffstat (limited to 'dh_strip')
-rwxr-xr-xdh_strip15
1 files changed, 13 insertions, 2 deletions
diff --git a/dh_strip b/dh_strip
index 49f3723..a62e440 100755
--- a/dh_strip
+++ b/dh_strip
@@ -53,6 +53,17 @@ if (defined $ENV{DEB_BUILD_OPTIONS} && $ENV{DEB_BUILD_OPTIONS} =~ /nostrip/) {
exit;
}
+# I could just use `file $_[0]`, but this is safer
+sub get_file_type {
+ my $file=shift;
+ open (FILE, '-|') # handle all filenames safely
+ || exec('file', $file)
+ || die "can't exec file: $!";
+ my $type=<FILE>;
+ close FILE;
+ return $type;
+}
+
# Check if a file is an elf binary, shared library, or static library,
# for use by File::Find. It'll fill the following 3 arrays with anything
# it finds:
@@ -70,7 +81,7 @@ sub testfile {
# Does its filename look like a shared library?
if (m/.*\.so.*?/) {
# Ok, do the expensive test.
- my $type=`file $_`;
+ my $type=get_file_type($_);
if ($type=~m/.*ELF.*shared.*/) {
push @shared_libs, $fn;
return;
@@ -81,7 +92,7 @@ sub testfile {
my (undef,undef,$mode,undef)=stat(_);
if ($mode & 0111) {
# Ok, expensive test.
- my $type=`file $_`;
+ my $type=get_file_type($_);
if ($type=~m/.*ELF.*executable.*/) {
push @executables, $fn;
return;