From: Thomas Lamprecht Date: Sat, 15 May 2021 11:00:46 +0000 (+0200) Subject: get tasklist: unpack null-terminated C string before decoding as JSON X-Git-Url: https://git.proxmox.com/?p=pve-cluster.git;a=commitdiff_plain;h=aea0f5a66f5bd0c68fcbe733675d66408e2486d7 get tasklist: unpack null-terminated C string before decoding as JSON This was always an "issue", but with Perl 5.28, from our Debian Buster based release, decode_json just ignored the \0 NUL byte. For example: ``` perl -w -MJSON -e 'my $raw = "[]\0"; print to_json(decode_json($raw), {pretty=>1});' ``` will get you the following error on perl 5.32 ``` garbage after JSON object, at character offset 2 (before "\x{0}") at -e line 1. ``` Note, I did not find anything related in the perldelta aricles for the 28 -> 30 or 30 -> 32 update, the first one made a bigger jump for the JSON module version used, so possibly a change there. Signed-off-by: Thomas Lamprecht --- diff --git a/data/PVE/Cluster.pm b/data/PVE/Cluster.pm index 3df2dbe..4d09c60 100644 --- a/data/PVE/Cluster.pm +++ b/data/PVE/Cluster.pm @@ -398,7 +398,8 @@ sub get_tasklist { if (!$cache || !$ver || !$cache->{version} || ($cache->{version} != $ver)) { my $tasks = []; if (my $raw = $ipcc_get_status->("tasklist", $node)) { - $tasks = decode_json($raw); + my $json_str = unpack("Z*", $raw); + $tasks = decode_json($json_str); } push @$res, @$tasks; $tasklistcache->{$node} = {