[pve-devel] [PATCH manager] fix #3037: include the split_list to shell_qoute

Wolfgang Bumiller w.bumiller at proxmox.com
Fri Jan 20 14:23:14 CET 2023


On Fri, Jan 20, 2023 at 01:38:23PM +0100, Moayad Almalat wrote:
> By including and using 'split_list' from PVE::Tools we can avoid the null
> (\000) bytes in the shell_quote() function, in which the 'split_list' takes
> a single argument, to return the array format.
> Thanks wolfgang.
> 
> Signed-off-by: Moayad Almalat <m.almalat at proxmox.com>
> ---
>  PVE/CLI/pvesh.pm | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/PVE/CLI/pvesh.pm b/PVE/CLI/pvesh.pm
> index 370fdb0e..c28a1588 100755
> --- a/PVE/CLI/pvesh.pm
> +++ b/PVE/CLI/pvesh.pm
> @@ -15,6 +15,7 @@ use PVE::CLIHandler;
>  use PVE::API2Tools;
>  use PVE::API2;
>  use JSON;
> +use PVE::Tools qw(split_list);
>  
>  use base qw(PVE::CLIHandler);
>  
> @@ -106,7 +107,7 @@ sub proxy_handler {
>      my $args = [];
>      foreach my $key (keys %$param) {
>  	next if $key eq 'quiet' || $key eq 'output-format'; # just to  be sure
> -	push @$args, "--$key", $param->{$key};
> +	push @$args, "--$key", $_ for split_list($param->{$key});

Looking at it again I think it might actually make more sense to just
use `split(/\0/, ...)` instead of `split_list()`, since I don't think we
want spaces, commas or semicolons cause splits here.

Given we're in a CLI tool here, I think this will always come as `\0`
separated data initially.

>      }
>  
>      my $remcmd = ['ssh', '-o', 'BatchMode=yes', "root\@$remip",
> -- 
> 2.30.2





More information about the pve-devel mailing list