[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libguestfs] [PATCH] Add a test for an executable stack in libguestfs.so



Matthew Booth wrote:
> ---
>  regressions/Makefile.am          |    4 ++-
...
> diff --git a/regressions/test-noexec-stack.pl b/regressions/test-noexec-stack.pl
...
> +FILES: foreach my $file (@files) {
> +    my $output;
> +    open($output, '-|', "readelf -l $file")
> +        or die("\"readelf -l $file\" failed");

Hi Matt,

A general tip:
There's a bit of a risk in opening a pipe like that.
Imagine that $file contains certain shell meta-characters (like "; rm -rf /").

Use an array, and you avoid that, as well as the duplication in the "die":

     my @cmd = ('readelf', '-l', $file);
     open($output, '-|', @cmd)
         or die "$0: failed to run: \`" . join(' ',@cmd) . "': $!\n";

Also, imho, every diagnostic should start with "$program_name: ".
That makes it easier to know which program produced a particular
string, when wading through thousands of lines of output from
hundreds of different tools.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]