]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: xml: Remove virXMLPropStringLimit and virXPathStringLimit
authorPeter Krempa <pkrempa@redhat.com>
Mon, 22 Nov 2021 16:44:49 +0000 (17:44 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 24 Nov 2021 08:20:39 +0000 (09:20 +0100)
The functions have very difficult semantics where callers are not able
to tell whether the property is missing or failed the length check. Only
the latter produces errors.

Since usage of the functions was phased out, remove them completely to
avoid further broken code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/libvirt_private.syms
src/util/virxml.c
src/util/virxml.h

index 95bf1db39d6462b35a59875bab164d252cc61612..b98cb0f66df26cd47727778abb4b1380baaa904b 100644 (file)
@@ -3627,7 +3627,6 @@ virXMLPropEnum;
 virXMLPropEnumDefault;
 virXMLPropInt;
 virXMLPropString;
-virXMLPropStringLimit;
 virXMLPropTristateBool;
 virXMLPropTristateSwitch;
 virXMLPropUInt;
@@ -3648,7 +3647,6 @@ virXPathNode;
 virXPathNodeSet;
 virXPathNumber;
 virXPathString;
-virXPathStringLimit;
 virXPathUInt;
 virXPathULong;
 virXPathULongHex;
index b736d59d9c0d76ac16124f30c8f03f8ea2a21952..4b09374107713c33800d9df156d10e1092e630e0 100644 (file)
@@ -89,45 +89,6 @@ virXPathString(const char *xpath,
 }
 
 
-static char *
-virXMLStringLimitInternal(char *value,
-                          size_t maxlen,
-                          const char *name)
-{
-    if (value != NULL && strlen(value) >= maxlen) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("'%s' value longer than '%zu' bytes"),
-                       name, maxlen);
-        VIR_FREE(value);
-        return NULL;
-    }
-
-    return value;
-}
-
-
-/**
- * virXPathStringLimit:
- * @xpath: the XPath string to evaluate
- * @maxlen: maximum length permitted string
- * @ctxt: an XPath context
- *
- * Wrapper for virXPathString, which validates the length of the returned
- * string.
- *
- * Returns a new string which must be deallocated by the caller or NULL if
- * the evaluation failed.
- */
-char *
-virXPathStringLimit(const char *xpath,
-                    size_t maxlen,
-                    xmlXPathContextPtr ctxt)
-{
-    char *tmp = virXPathString(xpath, ctxt);
-
-    return virXMLStringLimitInternal(tmp, maxlen, xpath);
-}
-
 /**
  * virXPathNumber:
  * @xpath: the XPath string to evaluate
@@ -492,29 +453,6 @@ virXMLPropString(xmlNodePtr node,
 }
 
 
-/**
- * virXMLPropStringLimit:
- * @node: XML dom node pointer
- * @name: Name of the property (attribute) to get
- * @maxlen: maximum permitted length of the string
- *
- * Wrapper for virXMLPropString, which validates the length of the returned
- * string.
- *
- * Returns a new string which must be deallocated by the caller or NULL if
- * the evaluation failed.
- */
-char *
-virXMLPropStringLimit(xmlNodePtr node,
-                      const char *name,
-                      size_t maxlen)
-{
-    char *tmp = (char *)xmlGetProp(node, BAD_CAST name);
-
-    return virXMLStringLimitInternal(tmp, maxlen, name);
-}
-
-
 /**
  * virXMLNodeContentString:
  * @node: XML dom node pointer
index 5e42fc35916bb425450f73dca2d03c8491c66498..c39eae62821bd99e4ab6264e3c8c9c40212f1f2e 100644 (file)
@@ -47,10 +47,6 @@ virXPathBoolean(const char *xpath,
 char *
 virXPathString(const char *xpath,
                xmlXPathContextPtr ctxt);
-char *
-virXPathStringLimit(const char *xpath,
-                    size_t maxlen,
-                    xmlXPathContextPtr ctxt);
 int
 virXPathNumber(const char *xpath,
                xmlXPathContextPtr ctxt,
@@ -98,10 +94,6 @@ char *
 virXMLPropString(xmlNodePtr node,
                  const char *name);
 char *
-virXMLPropStringLimit(xmlNodePtr node,
-                      const char *name,
-                      size_t maxlen);
-char *
 virXMLNodeContentString(xmlNodePtr node);
 
 int