Message ID | 20190207225026.11723-4-tobin@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Minor bug fixes to leaking_addresses.pl | expand |
On Thu, Feb 07, 2019 at 04:35:55PM -0700, Tycho Andersen wrote: > On Fri, Feb 08, 2019 at 09:50:26AM +1100, Tobin C. Harding wrote: > > Currently if user passes an output file to the script via > > --output-raw we do not handle expansion of tilde. > > > > Use perl function glob() to expand tilde in output file name. > > > > Signed-off-by: Tobin C. Harding <tobin@kernel.org> > > --- > > scripts/leaking_addresses.pl | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl > > index ef9e5b2a1614..ce545ca3fb70 100755 > > --- a/scripts/leaking_addresses.pl > > +++ b/scripts/leaking_addresses.pl > > @@ -150,7 +150,7 @@ if (!(is_supported_architecture() or $opt_32bit or $page_offset_32bit)) { > > } > > > > if ($output_raw) { > > - open my $fh, '>', $output_raw or die "$0: $output_raw: $!\n"; > > + open my $fh, '>', glob($output_raw) or die "$0: $output_raw: $!\n"; > > Seems like you might also have the same problem with $input_raw? I > wonder if you can just do this in GetOptions somehow, so that all > users of these further down in the script don't have to remember to do > this. Thanks for the review, good idea - I'll look into it. Tobin
From: Tobin C. Harding > Sent: 07 February 2019 22:50 > > Currently if user passes an output file to the script via > --output-raw we do not handle expansion of tilde. > > Use perl function glob() to expand tilde in output file name. What happens if glob() returns multiple files? I'm guessing that it can... David > Signed-off-by: Tobin C. Harding <tobin@kernel.org> > --- > scripts/leaking_addresses.pl | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl > index ef9e5b2a1614..ce545ca3fb70 100755 > --- a/scripts/leaking_addresses.pl > +++ b/scripts/leaking_addresses.pl > @@ -150,7 +150,7 @@ if (!(is_supported_architecture() or $opt_32bit or $page_offset_32bit)) { > } > > if ($output_raw) { > - open my $fh, '>', $output_raw or die "$0: $output_raw: $!\n"; > + open my $fh, '>', glob($output_raw) or die "$0: $output_raw: $!\n"; > select $fh; > } > > -- > 2.20.1 - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
On Wed, Feb 13, 2019 at 03:56:47PM +0000, David Laight wrote: > From: Tobin C. Harding > > Sent: 07 February 2019 22:50 > > > > Currently if user passes an output file to the script via > > --output-raw we do not handle expansion of tilde. > > > > Use perl function glob() to expand tilde in output file name. > > What happens if glob() returns multiple files? > I'm guessing that it can... Thanks for taking a look at this David. Surely glob() cannot return multiple values when expanding tilde? If someone passes a '*' into the command as an input/output file then they are clearly mad :) thanks, Tobin.
On Thu, Feb 07, 2019 at 04:35:55PM -0700, Tycho Andersen wrote: > On Fri, Feb 08, 2019 at 09:50:26AM +1100, Tobin C. Harding wrote: > > Currently if user passes an output file to the script via > > --output-raw we do not handle expansion of tilde. > > > > Use perl function glob() to expand tilde in output file name. > > > > Signed-off-by: Tobin C. Harding <tobin@kernel.org> > > --- > > scripts/leaking_addresses.pl | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl > > index ef9e5b2a1614..ce545ca3fb70 100755 > > --- a/scripts/leaking_addresses.pl > > +++ b/scripts/leaking_addresses.pl > > @@ -150,7 +150,7 @@ if (!(is_supported_architecture() or $opt_32bit or $page_offset_32bit)) { > > } > > > > if ($output_raw) { > > - open my $fh, '>', $output_raw or die "$0: $output_raw: $!\n"; > > + open my $fh, '>', glob($output_raw) or die "$0: $output_raw: $!\n"; > > Seems like you might also have the same problem with $input_raw? I > wonder if you can just do this in GetOptions somehow, so that all > users of these further down in the script don't have to remember to do > this. I don't know what changed between now and when I first wrote this patch (a fair while ago) but I just tested with bash and zsh _without_ this patch and tilde was handled fine. Dropping this patch, moving the other two onto leaks-next. thanks, Tobin.
From: Tobin C. Harding > Sent: 13 February 2019 20:31 > > On Wed, Feb 13, 2019 at 03:56:47PM +0000, David Laight wrote: > > From: Tobin C. Harding > > > Sent: 07 February 2019 22:50 > > > > > > Currently if user passes an output file to the script via > > > --output-raw we do not handle expansion of tilde. > > > > > > Use perl function glob() to expand tilde in output file name. > > > > What happens if glob() returns multiple files? > > I'm guessing that it can... > > Thanks for taking a look at this David. Surely glob() cannot return > multiple values when expanding tilde? If someone passes a '*' into the > command as an input/output file then they are clearly mad :) Yes, but the perl script will go horribly wrong. Actually, how do they get a ~ in there? Whatever shell generated perl's argv[] would be expected to handle it. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl index ef9e5b2a1614..ce545ca3fb70 100755 --- a/scripts/leaking_addresses.pl +++ b/scripts/leaking_addresses.pl @@ -150,7 +150,7 @@ if (!(is_supported_architecture() or $opt_32bit or $page_offset_32bit)) { } if ($output_raw) { - open my $fh, '>', $output_raw or die "$0: $output_raw: $!\n"; + open my $fh, '>', glob($output_raw) or die "$0: $output_raw: $!\n"; select $fh; }
Currently if user passes an output file to the script via --output-raw we do not handle expansion of tilde. Use perl function glob() to expand tilde in output file name. Signed-off-by: Tobin C. Harding <tobin@kernel.org> --- scripts/leaking_addresses.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)