From d1f4700063c527d787b21b68983f9b1f25b3c4fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Fri, 2 Oct 2020 13:55:15 +0200 Subject: [PATCH] file_size_info: handle dangling symlinks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit and other stat failure modes. this method returns undef if 'qemu-img info ...' fails to return information, so callers must handle this already. Signed-off-by: Fabian Grünbichler --- PVE/Storage/Plugin.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm index e6cd99c..63f68da 100644 --- a/PVE/Storage/Plugin.pm +++ b/PVE/Storage/Plugin.pm @@ -783,6 +783,12 @@ sub file_size_info { my $st = File::stat::stat($filename); + if (!defined($st)) { + my $extramsg = -l $filename ? ' - dangling symlink?' : ''; + warn "failed to stat '$filename'$extramsg\n"; + return undef; + } + if (S_ISDIR($st->mode)) { return wantarray ? (0, 'subvol', 0, undef, $st->ctime) : 1; }