Minor bug fixes to leaking_addresses.pl
cover Minor bug fixes to leaking_addresses.pl
Hi,
Here are a few minor fixes/improvements to scripts/leaking_addresses.pl
Patch 1: Fixes places where I don't know how to Perl.
Patch 2: Removes --version command line option, completely this time.
Patch 3: Fix a bug in the command line options parsing.
thanks,
Tobin.
Tobin C. Harding (3):
leaking_addresses: Fix calls to dprint
leaking_addresses: Completely remove --version flag
leaking_addresses: Expand tilde in output file name
scripts/leaking_addresses.pl | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/3 leaking_addresses: Fix calls to dprint
Currently calls to function dprint() are non uniform and at times incorrect.
Use uniform _correct_ call to function dprint().
--- scripts/leaking_addresses.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
scripts/leaking_addresses.pl +3 -3
@@ -231,7 +231,7 @@ sub get_kernel_config_option my $tmp_file = "/tmp/tmpkconf"; if (system("gunzip < /proc/config.gz > $tmp_file")) { - dprint "$0: system(gunzip < /proc/config.gz) failed\n"; + dprint("system(gunzip < /proc/config.gz) failed\n"); return ""; } else { @config_files = ($tmp_file);
@@ -243,7 +243,7 @@ sub get_kernel_config_option } foreach my $file (@config_files) { - dprint("parsing config file: %s\n", $file); + dprint("parsing config file: $file\n"); $value = option_from_file($option, $file); if ($value ne "") { last;
@@ -502,7 +502,7 @@ sub walk next; } - dprint "parsing: $path\n"; + dprint("parsing: $path\n"); timed_parse_file($path); } }
Signature · 1 line
2.20.1
PATCH 2/3 leaking_addresses: Completely remove --version flag
In reply to Tobin C. HardingRecently attempt to remove the '--version' flag was made, badly. I failed to remove mention of it from the help output. And also I failed to actually remove the flag from the options list.
_Completely_ remove --version flag.
--- scripts/leaking_addresses.pl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
scripts/leaking_addresses.pl +1 -2
@@ -97,7 +97,7 @@ Options: --32-bit Scan 32-bit kernel. --page-offset-32-bit=o Page offset (for 32-bit kernel 0xABCD1234). -d, --debug Display debugging output. - -h, --help, --version Display this help and exit. + -h, --help Display this help and exit. Scans the running kernel for potential leaking addresses.
@@ -108,7 +108,6 @@ EOM GetOptions( 'd|debug' => \$debug, 'h|help' => \$help, - 'version' => \$help, 'o|output-raw=s' => \$output_raw, 'i|input-raw=s' => \$input_raw, 'suppress-dmesg' => \$suppress_dmesg,
Signature · 1 line
2.20.1
PATCH 3/3 leaking_addresses: Expand tilde in output file name
In reply to Tobin C. HardingCurrently 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.
--- scripts/leaking_addresses.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/leaking_addresses.pl +1 -1
@@ -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; }
Signature · 1 line
2.20.1
Re: [PATCH 3/3] leaking_addresses: Expand tilde in output file name
Quoted 15 lines · Tobin C. Harding
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 <[email protected]>--- scripts/leaking_addresses.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/leaking_addresses.pl +0
-0
scripts/leaking_addresses.pl if (!(is_supported_architecture() or $opt_32bit or $page_offset_32bit)) { · line 153
Quoted 5 lines
scripts/leaking_addresses.pl +1
-1@@ -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.
Cheers,
Tycho
Re: [PATCH 3/3] leaking_addresses: Expand tilde in output file name
Quoted 18 lines · Tycho Andersen
Quoted 17 lines · Tobin C. Harding
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 <[email protected]>--- scripts/leaking_addresses.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/leaking_addresses.pl +0
-0@@ -150,7 +150,7 @@ if (!(is_supported_architecture() or $opt_32bit or $page_offset_32bit)) { }
Quoted 8 lines
scripts/leaking_addresses.pl if (!(is_supported_architecture() or $opt_32bit or $page_offset_32bit)) { · line 153
Quoted 3 lines
scripts/leaking_addresses.pl +1
-1if ($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
Re: [PATCH 3/3] leaking_addresses: Expand tilde in output file name
In reply to Tycho AndersenQuoted 18 lines · Tycho Andersen
Quoted 17 lines · Tobin C. Harding
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 <[email protected]>--- scripts/leaking_addresses.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/leaking_addresses.pl +0
-0@@ -150,7 +150,7 @@ if (!(is_supported_architecture() or $opt_32bit or $page_offset_32bit)) { }
Quoted 8 lines
scripts/leaking_addresses.pl if (!(is_supported_architecture() or $opt_32bit or $page_offset_32bit)) { · line 153
Quoted 3 lines
scripts/leaking_addresses.pl +1
-1if ($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.
RE: [PATCH 3/3] leaking_addresses: Expand tilde in output file name
In reply to Tobin C. HardingFrom: Tobin C. Harding
Quoted 6 lines
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
Quoted 19 lines
Signed-off-by Tobin C. Harding <[email protected]>--- scripts/leaking_addresses.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/leaking_addresses.pl +1
-2@@ -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; } --
Quoted 1 line
2.20.1
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Re: [PATCH 3/3] leaking_addresses: Expand tilde in output file name
Quoted 10 lines · David Laight
From: Tobin C. Harding
Quoted 6 lines
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.
RE: [PATCH 3/3] leaking_addresses: Expand tilde in output file name
From: Tobin C. Harding
Quoted 9 lines
Sent: 13 February 2019 20:31
Quoted 6 lines · David Laight
From: Tobin C. Harding
Quoted 5 lines
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.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
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)