From 1ff3d18528c24effc721f6e0a6b31c46cb5f0071 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Thu, 16 Oct 2025 11:09:18 +0100 Subject: [PATCH] tools/nss: check for missing array element MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Daniel P. Berrangé --- tools/nss/libvirt_nss_macs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/nss/libvirt_nss_macs.c b/tools/nss/libvirt_nss_macs.c index 44544624f3..1110848060 100644 --- a/tools/nss/libvirt_nss_macs.c +++ b/tools/nss/libvirt_nss_macs.c @@ -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; -- 2.47.3