mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-29 09:16:33 +00:00
leaking_addresses: Use File::Temp for /tmp files
Instead of using a statically named path in /tmp, use File::Temp to create (and remove) the temporary file used for parsing /proc/config.gz. Reviewed-by: Tycho Andersen <tandersen@netflix.com> Link: https://lore.kernel.org/r/20240222220053.1475824-2-keescook@chromium.org Signed-off-by: Kees Cook <keescook@chromium.org>
This commit is contained in:
parent
616cfbf30b
commit
1b1bcbf454
@ -23,6 +23,7 @@ use strict;
|
||||
use POSIX;
|
||||
use File::Basename;
|
||||
use File::Spec;
|
||||
use File::Temp qw/tempfile/;
|
||||
use Cwd 'abs_path';
|
||||
use Term::ANSIColor qw(:constants);
|
||||
use Getopt::Long qw(:config no_auto_abbrev);
|
||||
@ -221,6 +222,7 @@ sub get_kernel_config_option
|
||||
{
|
||||
my ($option) = @_;
|
||||
my $value = "";
|
||||
my $tmp_fh;
|
||||
my $tmp_file = "";
|
||||
my @config_files;
|
||||
|
||||
@ -228,7 +230,8 @@ sub get_kernel_config_option
|
||||
if ($kernel_config_file ne "") {
|
||||
@config_files = ($kernel_config_file);
|
||||
} elsif (-R "/proc/config.gz") {
|
||||
my $tmp_file = "/tmp/tmpkconf";
|
||||
($tmp_fh, $tmp_file) = tempfile("config.gz-XXXXXX",
|
||||
UNLINK => 1);
|
||||
|
||||
if (system("gunzip < /proc/config.gz > $tmp_file")) {
|
||||
dprint("system(gunzip < /proc/config.gz) failed\n");
|
||||
@ -250,10 +253,6 @@ sub get_kernel_config_option
|
||||
}
|
||||
}
|
||||
|
||||
if ($tmp_file ne "") {
|
||||
system("rm -f $tmp_file");
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user