]> xenbits.xensource.com Git - 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 16:41:20 +0000 (18:41 +0200)
Including them in the XML makes them unparsable.

https://bugzilla.redhat.com/show_bug.cgi?id=1184131

src/node_device/node_device_udev.c

index 1025e802d1bc53811cbec1a879fe5374c688c394..846f57014668a1302c385d7aac034b933503066e 100644 (file)
@@ -191,7 +191,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)
@@ -233,6 +235,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;