]> git.proxmox.com Git - pve-common.git/commitdiff
fix Tools::df for big storage usage values
authorDominik Csapak <d.csapak@proxmox.com>
Tue, 12 Nov 2019 12:56:20 +0000 (13:56 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 12 Nov 2019 13:12:02 +0000 (14:12 +0100)
if the size/avail of a mount is bigger than a certain amount,
json_encode writes the number in scientific format, which was not
matched by our \d+ regex.

This then resulted in 'undef' values for the result hash and
subsequently led to errors and warnings.

Extend the regex to also match scientific formatted numbers,
perl can then use them as is, no need for any conversion.

https://forum.proxmox.com/threads/bug-in-pve-tools-df-when-adding-petabyte-scale-storage.60090/#post-277050

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/Tools.pm

index 02c28867f0c2d4ec038d0115063eb2895549372b..89de4ecff288a048447063a55311453b2865098c 100644 (file)
@@ -1008,7 +1008,7 @@ sub df {
     warn $@ if $@;
 
     # untaint the values
-    my ($blocks, $used, $bavail) = map { defined($_) ? (/^(\d+)$/) : 0 }
+    my ($blocks, $used, $bavail) = map { defined($_) ? (/^([\d\.e\-+]+)$/) : 0 } # can be in scientific notation
        $res->@{qw(blocks used bavail)};
 
     return {