]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virSecurityDeviceLabelDefParseXML: Don't use 'virXPathStringLimit'
authorPeter Krempa <pkrempa@redhat.com>
Mon, 22 Nov 2021 16:26:40 +0000 (17:26 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 24 Nov 2021 08:20:39 +0000 (09:20 +0100)
virXPathStringLimit doesn't give callers a way to differentiate between
the queried XPath being empty and the length limit being exceeded.

This means that the callers is completely ignoring the error.

Move the length check into the caller.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/conf/domain_conf.c

index 57ab4c060b4474e3bc48c6c2441f73963fba10dc..13395a70235ac13b95a9434f5195c7e3dcc366f5 100644 (file)
@@ -8065,9 +8065,10 @@ virSecurityDeviceLabelDefParseXML(virSecurityDeviceLabelDef ***seclabels_rtn,
             ignore_value(virStringParseYesNo(labelskip, &seclabels[i]->labelskip));
 
         ctxt->node = list[i];
-        label = virXPathStringLimit("string(./label)",
-                                    VIR_SECURITY_LABEL_BUFLEN-1, ctxt);
-        seclabels[i]->label = g_steal_pointer(&label);
+        label = virXPathString("string(./label)", ctxt);
+
+        if (label && strlen(label) < VIR_SECURITY_LABEL_BUFLEN)
+            seclabels[i]->label = g_steal_pointer(&label);
 
         if (seclabels[i]->label && !seclabels[i]->relabel) {
             virReportError(VIR_ERR_XML_ERROR,