hal: Branch 'master'
Danny Kukawka
dkukawka at kemper.freedesktop.org
Fri Jan 12 12:17:34 PST 2007
hald/linux/device.c | 28 ++++++++++++++++------------
1 files changed, 16 insertions(+), 12 deletions(-)
New commits:
diff-tree e8ab03c7230ff52adb6a8ef77f28e3dfcfda6037 (from 4faf1889374ed46af0081adcf20b11291e76efef)
Author: Danny Kukawka <danny.kukawka at web.de>
Date: Fri Jan 12 21:16:52 2007 +0100
fixed segmentation fault in xen code
This fix a potential segmentation fault in xen_add() because of use a
NULL within strcmp() if the file devtype is missing in sysfs for a xen
device.
diff --git a/hald/linux/device.c b/hald/linux/device.c
index 7508958..adeee05 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -1811,20 +1811,24 @@ xen_add (const gchar *sysfs_path, const
hal_util_set_string_from_file (d, "xen.path", sysfs_path, "nodename");
devtype = hal_util_get_string_from_file (sysfs_path, "devtype");
- hal_device_property_set_string (d, "xen.type", devtype);
+ if (devtype != NULL) {
+ hal_device_property_set_string (d, "xen.type", devtype);
- if (strcmp (devtype, "pci") == 0) {
- hal_device_property_set_string (d, "info.product", "Xen PCI Device");
- } else if (strcmp (devtype, "vbd") == 0) {
- hal_device_property_set_string (d, "info.product", "Xen Virtual Block Device");
- } else if (strcmp (devtype, "vif") == 0) {
- hal_device_property_set_string (d, "info.product", "Xen Virtual Network Device");
- } else if (strcmp (devtype, "vtpm") == 0) {
- hal_device_property_set_string (d, "info.product", "Xen Virtual Trusted Platform Module");
+ if (strcmp (devtype, "pci") == 0) {
+ hal_device_property_set_string (d, "info.product", "Xen PCI Device");
+ } else if (strcmp (devtype, "vbd") == 0) {
+ hal_device_property_set_string (d, "info.product", "Xen Virtual Block Device");
+ } else if (strcmp (devtype, "vif") == 0) {
+ hal_device_property_set_string (d, "info.product", "Xen Virtual Network Device");
+ } else if (strcmp (devtype, "vtpm") == 0) {
+ hal_device_property_set_string (d, "info.product", "Xen Virtual Trusted Platform Module");
+ } else {
+ char buf[64];
+ g_snprintf (buf, sizeof (buf), "Xen Device (%s)", devtype);
+ hal_device_property_set_string (d, "info.product", buf);
+ }
} else {
- char buf[64];
- g_snprintf (buf, sizeof (buf), "Xen Device (%s)", devtype);
- hal_device_property_set_string (d, "info.product", buf);
+ hal_device_property_set_string (d, "info.product", "Xen Device (unknown)");
}
return d;
More information about the hal-commit
mailing list