mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
edit: Clean up tmp file handling in virt-edit.
This was probably not a security issue, but this change makes the code cleaner by not opening the tmp file twice. Also be more careful about error checking in close syscall.
This commit is contained in:
@@ -198,10 +198,13 @@ my $root_dev = $roots[0];
|
||||
my $os = $oses->{$root_dev};
|
||||
mount_operating_system ($g, $os, 0);
|
||||
|
||||
my ($fh_not_used, $tempname) = tempfile (UNLINK => 1);
|
||||
my ($fh, $tempname) = tempfile (UNLINK => 1);
|
||||
my $fddev = "/dev/fd/" . fileno ($fh);
|
||||
|
||||
# Allow this to fail in case eg. the file does not exist.
|
||||
$g->download($filename, $tempname);
|
||||
$g->download ($filename, $fddev);
|
||||
|
||||
close $fh or die "close: $!";
|
||||
|
||||
my $do_upload = $tempname;
|
||||
|
||||
@@ -232,7 +235,7 @@ if (!defined $expr) {
|
||||
die if $@;
|
||||
print $fh $_ or die "print: $!";
|
||||
}
|
||||
close $fh;
|
||||
close $fh or die "close: $!";
|
||||
|
||||
$do_upload = $tempout;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user