fix some segvs and drive detection

SVN revision: 60832
This commit is contained in:
Mike Blumenkrantz 2011-06-29 18:53:38 +00:00
parent 47cdbe390a
commit f2caf4707c
2 changed files with 15 additions and 11 deletions

View File

@ -42,3 +42,6 @@
* fixed eeze_udev_find_unlisted_similar to be less permissive * fixed eeze_udev_find_unlisted_similar to be less permissive
* added EEZE_EVENT_DISK_EJECT and eeze_disk_eject, functions for ejecting a disk * added EEZE_EVENT_DISK_EJECT and eeze_disk_eject, functions for ejecting a disk
2011-06-29 Mike Blumenkrantz (discomfitor/zmike)
* fixed bug where EEZE_UDEV_EVENT_NONE would not match all events for watches
* fixed segv when detecting removable drives

View File

@ -66,39 +66,40 @@ _get_syspath_from_watch(void *data,
{ {
if (!strcmp(test, "add")) if (!strcmp(test, "add"))
{ {
if ((store->event & EEZE_UDEV_EVENT_ADD) != EEZE_UDEV_EVENT_ADD) if ((store->event != EEZE_UDEV_EVENT_NONE) &&
((store->event & EEZE_UDEV_EVENT_ADD) != EEZE_UDEV_EVENT_ADD))
goto error; goto error;
event |= EEZE_UDEV_EVENT_ADD; event |= EEZE_UDEV_EVENT_ADD;
} }
else if (!strcmp(test, "remove")) else if (!strcmp(test, "remove"))
{ {
if ((store->event & EEZE_UDEV_EVENT_REMOVE) != if ((store->event != EEZE_UDEV_EVENT_NONE) &&
EEZE_UDEV_EVENT_REMOVE) ((store->event & EEZE_UDEV_EVENT_REMOVE) != EEZE_UDEV_EVENT_REMOVE))
goto error; goto error;
event |= EEZE_UDEV_EVENT_REMOVE; event |= EEZE_UDEV_EVENT_REMOVE;
} }
else if (!strcmp(test, "change")) else if (!strcmp(test, "change"))
{ {
if ((store->event & EEZE_UDEV_EVENT_CHANGE) != if ((store->event != EEZE_UDEV_EVENT_NONE) &&
EEZE_UDEV_EVENT_CHANGE) ((store->event & EEZE_UDEV_EVENT_CHANGE) != EEZE_UDEV_EVENT_CHANGE))
goto error; goto error;
event |= EEZE_UDEV_EVENT_CHANGE; event |= EEZE_UDEV_EVENT_CHANGE;
} }
else if (!strcmp(test, "online")) else if (!strcmp(test, "online"))
{ {
if ((store->event & EEZE_UDEV_EVENT_ONLINE) != if ((store->event != EEZE_UDEV_EVENT_NONE) &&
EEZE_UDEV_EVENT_ONLINE) ((store->event & EEZE_UDEV_EVENT_ONLINE) != EEZE_UDEV_EVENT_ONLINE))
goto error; goto error;
event |= EEZE_UDEV_EVENT_ONLINE; event |= EEZE_UDEV_EVENT_ONLINE;
} }
else else
{ {
if ((store->event & EEZE_UDEV_EVENT_OFFLINE) != if ((store->event != EEZE_UDEV_EVENT_NONE) &&
EEZE_UDEV_EVENT_OFFLINE) ((store->event & EEZE_UDEV_EVENT_OFFLINE) != EEZE_UDEV_EVENT_OFFLINE))
goto error; goto error;
event |= EEZE_UDEV_EVENT_OFFLINE; event |= EEZE_UDEV_EVENT_OFFLINE;
@ -187,14 +188,14 @@ _get_syspath_from_watch(void *data,
case EEZE_UDEV_TYPE_DRIVE_INTERNAL: case EEZE_UDEV_TYPE_DRIVE_INTERNAL:
if (udev_device_get_property_value(device, "ID_FS_USAGE")) goto error; if (udev_device_get_property_value(device, "ID_FS_USAGE")) goto error;
test = udev_device_get_sysattr_value(device, "removable"); test = udev_device_get_sysattr_value(device, "removable");
if (test[0] == '1') goto error; if (test && test[0] == '1') goto error;
break; break;
case EEZE_UDEV_TYPE_DRIVE_REMOVABLE: case EEZE_UDEV_TYPE_DRIVE_REMOVABLE:
if (udev_device_get_property_value(device, "ID_FS_USAGE")) goto error; if (udev_device_get_property_value(device, "ID_FS_USAGE")) goto error;
test = udev_device_get_sysattr_value(device, "removable"); test = udev_device_get_sysattr_value(device, "removable");
if (test[0] == '0') goto error; if ((!test) || (test[0] == '0')) goto error;
break; break;