]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tools/nss: check for missing array element
authorDaniel P. Berrangé <berrange@redhat.com>
Thu, 16 Oct 2025 10:09:18 +0000 (11:09 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Fri, 7 Nov 2025 11:58:35 +0000 (11:58 +0000)
We've already checked the upper bound of the array, but we should
none the less sanity check that the requested array element is
not NULL before dereferencing it.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
tools/nss/libvirt_nss_macs.c

index 44544624f37bf6276de5f30cd2a518747ca69248..111084806058ce3a9d09bcecb538f2de0ecaf93d 100644 (file)
@@ -101,6 +101,8 @@ findMACsFromJSON(json_object *jobj,
             char *macstr;
 
             macobj = json_object_array_get_idx(macsArray, j);
+            if (!macobj)
+                return -1;
             macstr = strdup(json_object_get_string(macobj));
             if (!macstr)
                 return -1;