dnsexit2: Check for JSON object, not just truthiness

This commit is contained in:
Richard Hansen 2024-07-24 18:49:43 -04:00
parent 4a394f4562
commit 1c94ed6063

View file

@ -4028,8 +4028,8 @@ sub dnsexit2_update_host {
} }
(my $body = $reply) =~ s/^.*?\r?\n\r?\n//s; (my $body = $reply) =~ s/^.*?\r?\n\r?\n//s;
my $response = eval { decode_json($body); }; my $response = eval { decode_json($body); };
if (!$response) { if (ref($response) ne 'HASH') {
failed("$h: failed to parse response: $@"); failed("$h: response is not a JSON object:\n$body");
return; return;
} }
if (!defined($response->{'code'}) || !defined($response->{'message'})) { if (!defined($response->{'code'}) || !defined($response->{'message'})) {