[pve-devel] applied: [PATCH common] fix PVE::Tools::df for big mounts

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Nov 12 14:18:32 CET 2019


On 11/12/19 1:56 PM, Dominik Csapak wrote:
> if the size/avail of a mount is bigger than a certain amount,
> json_encode writes the number in scientific format, which did not
> fit inside our \d+ regex
> 
> this resulted in 'undef' values for the result hash and subsequently
> led to errors and warnings
> 
> extend it to also catch scientific formatted numbers
> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
>  src/PVE/Tools.pm | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

applied, changed the commit message a bit, e.g., linked the forum thread
and noted that perl itself can use such format as is. Thanks!

> diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm
> index 02c2886..89de4ec 100644
> --- a/src/PVE/Tools.pm
> +++ b/src/PVE/Tools.pm
> @@ -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

followed up with moving above comment into the untaint one,
avoiding very long lines, if not really necessary.

>  	$res->@{qw(blocks used bavail)};
>  
>      return {
> 





More information about the pve-devel mailing list