render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
c5b0b3
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
c5b0b3
Date: Tue, 14 Apr 2015 12:30:34 +0200
c5b0b3
Subject: [PATCH] Strip control characters from sysfs attributes
c5b0b3
c5b0b3
Including them in the XML makes them unparsable.
c5b0b3
c5b0b3
https://bugzilla.redhat.com/show_bug.cgi?id=1184131
c5b0b3
(cherry picked from commit 557107500b22d4a5ba7d1b09f5f516512dfca67b)
c5b0b3
---
c5b0b3
 src/node_device/node_device_udev.c | 6 +++++-
c5b0b3
 1 file changed, 5 insertions(+), 1 deletion(-)
c5b0b3
c5b0b3
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
c5b0b3
index 8c39e5f..0d691e0 100644
c5b0b3
--- a/src/node_device/node_device_udev.c
c5b0b3
+++ b/src/node_device/node_device_udev.c
c5b0b3
@@ -194,7 +194,9 @@ static int udevGetUintProperty(struct udev_device *udev_device,
c5b0b3
 
c5b0b3
 
c5b0b3
 /* This function allocates memory from the heap for the property
c5b0b3
- * value.  That memory must be later freed by some other code. */
c5b0b3
+ * value.  That memory must be later freed by some other code.
c5b0b3
+ * Any control characters that cannot be printed in the XML are stripped
c5b0b3
+ * from the string */
c5b0b3
 static int udevGetDeviceSysfsAttr(struct udev_device *udev_device,
c5b0b3
                                   const char *attr_name,
c5b0b3
                                   char **attr_value)
c5b0b3
@@ -239,6 +241,8 @@ static int udevGetStringSysfsAttr(struct udev_device *udev_device,
c5b0b3
 
c5b0b3
     ret = udevGetDeviceSysfsAttr(udev_device, attr_name, &tmp);
c5b0b3
 
c5b0b3
+    virStringStripControlChars(tmp);
c5b0b3
+
c5b0b3
     if (tmp != NULL && (STREQ(tmp, ""))) {
c5b0b3
         VIR_FREE(tmp);
c5b0b3
         tmp = NULL;