summaryrefslogtreecommitdiff
path: root/dh_strip
diff options
context:
space:
mode:
authorNiels Thykier <niels@thykier.net>2019-07-13 14:06:29 +0000
committerNiels Thykier <niels@thykier.net>2019-07-13 14:06:29 +0000
commit3ab5772719d91057ac70b2b32fd659e016418deb (patch)
treeb61213d602e2daa57069a7196b731e86e1cae225 /dh_strip
parent3eee6801905dc62dad6c139cf24f0c0cbcff274e (diff)
downloaddebhelper-3ab5772719d91057ac70b2b32fd659e016418deb.tar.gz
dh_strip: Be more robust about catching errors from file(1)
Signed-off-by: Niels Thykier <niels@thykier.net>
Diffstat (limited to 'dh_strip')
-rwxr-xr-xdh_strip14
1 files changed, 8 insertions, 6 deletions
diff --git a/dh_strip b/dh_strip
index 06122b14..9287a0c5 100755
--- a/dh_strip
+++ b/dh_strip
@@ -260,12 +260,14 @@ sub write_buildid_file {
sub get_file_type {
my ($file, $cache_ok) = @_;
return $file_output{$file} if $cache_ok && $file_output{$file};
- open (FILE, '-|') # handle all filenames safely
- || exec('file', '-e', 'apptype', '-e', 'ascii', '-e', 'encoding',
- '-e', 'cdf', '-e', 'compress', '-e', 'tar', $file)
- || die "can't exec file: $!";
- my $type=<FILE>;
- close FILE;
+ my @cmdline = ('file', '-e', 'apptype', '-e', 'ascii', '-e', 'encoding', '-e', 'cdf', '-e', 'compress', '-e',
+ 'tar', $file);
+
+ open(my $fd, '-|', @cmdline) // error("cannot fork+exec file: $!");
+ my $type = <$fd>;
+ close($fd) || error_exitcode(escape_shell(@cmdline));
+
+ error("file(1) gave no result for $file!?") if (not $type) ;
return $file_output{$file} = $type;
}