]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Strip control characters from sysfs attributes
authorJán Tomko <jtomko@redhat.com>
Tue, 14 Apr 2015 10:30:34 +0000 (12:30 +0200)
committerJán Tomko <jtomko@redhat.com>
Wed, 15 Apr 2015 17:26:26 +0000 (19:26 +0200)
Including them in the XML makes them unparsable.

https://bugzilla.redhat.com/show_bug.cgi?id=1184131
(cherry picked from commit 557107500b22d4a5ba7d1b09f5f516512dfca67b)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
src/node_device/node_device_udev.c

index 53792f0ecef89f4131eb22fb7814443fce5edf5c..3288ba1c1c4ab0f8945a93fd62c30bcb60a59858 100644 (file)
@@ -198,7 +198,9 @@ static int udevGetUintProperty(struct udev_device *udev_device,
 
 
 /* This function allocates memory from the heap for the property
- * value.  That memory must be later freed by some other code. */
+ * value.  That memory must be later freed by some other code.
+ * Any control characters that cannot be printed in the XML are stripped
+ * from the string */
 static int udevGetDeviceSysfsAttr(struct udev_device *udev_device,
                                   const char *attr_name,
                                   char **attr_value)
@@ -243,6 +245,8 @@ static int udevGetStringSysfsAttr(struct udev_device *udev_device,
 
     ret = udevGetDeviceSysfsAttr(udev_device, attr_name, &tmp);
 
+    virStringStripControlChars(tmp);
+
     if (tmp != NULL && (STREQ(tmp, ""))) {
         VIR_FREE(tmp);
         tmp = NULL;