]> 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)
committerCole Robinson <crobinso@redhat.com>
Mon, 27 Apr 2015 23:14:32 +0000 (19:14 -0400)
Including them in the XML makes them unparsable.

https://bugzilla.redhat.com/show_bug.cgi?id=1184131
(cherry picked from commit 557107500b22d4a5ba7d1b09f5f516512dfca67b)

src/node_device/node_device_udev.c

index 03c7a0b7b16341d62d76374d31fe354f983dbda7..eb6209bea17bb101d4a2dcb11ad636f742cda329 100644 (file)
@@ -194,7 +194,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)
@@ -239,6 +241,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;