From: Anastasia Belova Date: Wed, 16 Jul 2025 13:42:14 +0000 (+0300) Subject: virshFindDisk: fix NULL-dereference of xmlCopyNode() result X-Git-Tag: v11.6.0-rc1~105 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1eaaec533abbad52a40c282f1f1d009248c08e3d;p=thirdparty%2Flibvirt.git virshFindDisk: fix NULL-dereference of xmlCopyNode() result xmlCopyNode() may return NULL. Add a check and log an error in this case. Found by Linux Verification Center (linuxtesting.org) with Svace. Fixes: 22766a1a53 ("virshFindDisk: Sanitize use of 'tmp' variable") Signed-off-by: Anastasia Belova Reviewed-by: Peter Krempa --- diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 7253596f4a..6e18d195e6 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -12875,6 +12875,10 @@ virshFindDisk(const char *doc, STREQ_NULLABLE(sourceDir, path) || STREQ_NULLABLE(sourceName, path)) { xmlNodePtr ret = xmlCopyNode(nodes[i], 1); + if (!ret) { + vshError(NULL, "%s", _("Failed to copy XML node")); + return NULL; + } /* drop backing store since they are not needed here */ virshDiskDropBackingStore(ret); return ret;