From 8f9bc6e5f65e61889cab59d38e4899d309543ea4 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Mon, 22 Nov 2021 17:17:24 +0100 Subject: [PATCH] virNodeDeviceCapVPDParseCustomFields: Don't use 'virXPathStringLimit' MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit virXPathStringLimit doesn't give callers a way to differentiate between the queried XPath being empty and the length limit being exceeded. This means that callers are overwriting the error message. Move the length checks into the caller. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/conf/node_device_conf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index ca534dfbed..0bac0fde8d 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -955,7 +955,8 @@ virNodeDeviceCapVPDParseCustomFields(xmlXPathContextPtr ctxt, virPCIVPDResource g_autofree char *keyword = NULL; ctxt->node = nodes[i]; - if (!(index = virXPathStringLimit("string(./@index[1])", 2, ctxt))) { + if (!(index = virXPathString("string(./@index[1])", ctxt)) || + strlen(index) > 1) { virReportError(VIR_ERR_XML_ERROR, "%s", _(" evaluation has failed")); continue; @@ -983,7 +984,8 @@ virNodeDeviceCapVPDParseCustomFields(xmlXPathContextPtr ctxt, virPCIVPDResource VIR_XPATH_NODE_AUTORESTORE(ctxt); ctxt->node = nodes[i]; - if (!(index = virXPathStringLimit("string(./@index[1])", 2, ctxt))) { + if (!(index = virXPathString("string(./@index[1])", ctxt)) || + strlen(index) > 1) { virReportError(VIR_ERR_XML_ERROR, "%s", _(" evaluation has failed")); continue; -- 2.47.2