[systemd-commits] 2 commits - src/libudev
Kay Sievers
kay at kemper.freedesktop.org
Wed Sep 4 10:50:54 PDT 2013
src/libudev/libudev-enumerate.c | 5 +++++
1 file changed, 5 insertions(+)
New commits:
commit 756c9a2499ca377b9e96ea6fc6911ff64040174e
Author: Kay Sievers <kay at vrfy.org>
Date: Wed Sep 4 17:59:14 2013 +0200
libudev: enumerate - do not try to match against an empty subsystem
diff --git a/src/libudev/libudev-enumerate.c b/src/libudev/libudev-enumerate.c
index 385829d..bc1e37d 100644
--- a/src/libudev/libudev-enumerate.c
+++ b/src/libudev/libudev-enumerate.c
@@ -721,12 +721,14 @@ static bool match_subsystem(struct udev_enumerate *udev_enumerate, const char *s
{
struct udev_list_entry *list_entry;
- subsystem = subsystem ? : "";
+ if (!subsystem)
+ return false;
udev_list_entry_foreach(list_entry, udev_list_get_entry(&udev_enumerate->subsystem_nomatch_list)) {
if (fnmatch(udev_list_entry_get_name(list_entry), subsystem, 0) == 0)
return false;
}
+
if (udev_list_get_entry(&udev_enumerate->subsystem_match_list) != NULL) {
udev_list_entry_foreach(list_entry, udev_list_get_entry(&udev_enumerate->subsystem_match_list)) {
if (fnmatch(udev_list_entry_get_name(list_entry), subsystem, 0) == 0)
@@ -734,6 +736,7 @@ static bool match_subsystem(struct udev_enumerate *udev_enumerate, const char *s
}
return false;
}
+
return true;
}
commit f9e84da678cc28998fb04bf5ba326d91fc2850fa
Author: David Herrmann <dh.herrmann at gmail.com>
Date: Fri Aug 30 15:50:41 2013 +0200
libudev: enumerate: fix NULL-deref for subsystem-matches
udev_device_get_subsystem() may return NULL if no subsystem could be
figured out by libudev. This might be due to OOM or if the device
disconnected between the udev_device_new() call and
udev_device_get_subsystem(). Therefore, we need to handle subsystem==NULL
safely.
Instead of testing for it in each helper, we treat subsystem==NULL as
empty subsystem in match_subsystem().
Backtrace of udev_enumerate with an input-device disconnecting in exactly
this time-frame:
(gdb) bt
#0 0x00007ffff569dc24 in strnlen () from /usr/lib/libc.so.6
#1 0x00007ffff56d9e04 in fnmatch@@GLIBC_2.2.5 () from /usr/lib/libc.so.6
#2 0x00007ffff5beb83d in match_subsystem (udev_enumerate=0x7a05f0, subsystem=0x0) at src/libudev/libudev-enumerate.c:727
#3 0x00007ffff5bebb30 in parent_add_child (enumerate=enumerate at entry=0x7a05f0, path=<optimized out>) at src/libudev/libudev-enumerate.c:834
#4 0x00007ffff5bebc3f in parent_crawl_children (enumerate=enumerate at entry=0x7a05f0, path=0x7a56b0 "/sys/devices/<shortened>/input/input97", maxdepth=maxdepth at entry=254) at src/libudev/libudev-enumerate.c:866
#5 0x00007ffff5bebc54 in parent_crawl_children (enumerate=enumerate at entry=0x7a05f0, path=0x79e8c0 "/sys/devices/<shortened>/input", maxdepth=maxdepth at entry=255) at src/libudev/libudev-enumerate.c:868
#6 0x00007ffff5bebc54 in parent_crawl_children (enumerate=enumerate at entry=0x7a05f0, path=path at entry=0x753190 "/sys/devices/<shortened>", maxdepth=maxdepth at entry=256) at src/libudev/libudev-enumerate.c:868
#7 0x00007ffff5bec7df in scan_devices_children (enumerate=0x7a05f0) at src/libudev/libudev-enumerate.c:882
#8 udev_enumerate_scan_devices (udev_enumerate=udev_enumerate at entry=0x7a05f0) at src/libudev/libudev-enumerate.c:919
#9 0x00007ffff5df8777 in <random_caller> () at some/file.c:181
diff --git a/src/libudev/libudev-enumerate.c b/src/libudev/libudev-enumerate.c
index b96e5b2..385829d 100644
--- a/src/libudev/libudev-enumerate.c
+++ b/src/libudev/libudev-enumerate.c
@@ -721,6 +721,8 @@ static bool match_subsystem(struct udev_enumerate *udev_enumerate, const char *s
{
struct udev_list_entry *list_entry;
+ subsystem = subsystem ? : "";
+
udev_list_entry_foreach(list_entry, udev_list_get_entry(&udev_enumerate->subsystem_nomatch_list)) {
if (fnmatch(udev_list_entry_get_name(list_entry), subsystem, 0) == 0)
return false;
More information about the systemd-commits
mailing list