summaryrefslogtreecommitdiffstats
path: root/perl
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-09-28 10:15:13 +0100
committerRichard W.M. Jones <rjones@redhat.com>2012-09-28 15:09:50 +0100
commit9ea6e9701461e594033999150f930cc4fafec4d2 (patch)
tree4a8263f54426f05fc9da841681d7e54dfe8a595a /perl
parent55b7c4df7895b8c22d737723d857a9a63db69926 (diff)
downloadlibguestfs-9ea6e9701461e594033999150f930cc4fafec4d2.tar.gz
libguestfs-9ea6e9701461e594033999150f930cc4fafec4d2.tar.xz
libguestfs-9ea6e9701461e594033999150f930cc4fafec4d2.zip
inspection: Fix calls to case_sensitive_path (RHBZ#858126).
Don't assume that if guestfs_case_sensitive_path returns NULL, that it means the file does not exist. The (previously undefined) behaviour of case_sensitive_path was that a NULL return meant "either the file doesn't exist or some other error". However in commit 973581780d8a006f336684fef6762801402d775d this was changed so that if the last element of the path didn't exist, it was assumed to be a new file and the (non-NULL) path of the new file is returned. This change breaks code (including in libguestfs) which tries to use case_sensitive_path as a dual-purpose call to fix-up a path for Windows and test if the file exists. Such code should be rewritten so that it explicitly tests for file existence after calling case_sensitive_path. I examined all the calls to case_sensitive_path in libguestfs and modified them where necessary.
Diffstat (limited to 'perl')
-rw-r--r--perl/lib/Sys/Guestfs/Lib.pm3
1 files changed, 3 insertions, 0 deletions
diff --git a/perl/lib/Sys/Guestfs/Lib.pm b/perl/lib/Sys/Guestfs/Lib.pm
index 33e8acb8..5dde409c 100644
--- a/perl/lib/Sys/Guestfs/Lib.pm
+++ b/perl/lib/Sys/Guestfs/Lib.pm
@@ -356,6 +356,9 @@ sub resolve_windows_path
my $r;
eval { $r = $g->case_sensitive_path ($path); };
+
+ $r = undef if defined $r && ! $g->exists ($r);
+
return $r;
}