summaryrefslogtreecommitdiff
path: root/libudev/libudev-device.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2010-04-21 14:44:33 +0200
committerKay Sievers <kay.sievers@vrfy.org>2010-04-21 14:44:33 +0200
commit60067cc75ac7dd583beea584f87f2f6d3358f3c1 (patch)
tree79e2b1cc2ebc5d2f7a8c6b99a3b75cf72a4e3719 /libudev/libudev-device.c
parente925018786d85fb3aed3b62a0a89309f9a7d5e4f (diff)
more readlink buffer size handling
Diffstat (limited to 'libudev/libudev-device.c')
-rw-r--r--libudev/libudev-device.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/libudev/libudev-device.c b/libudev/libudev-device.c
index b3b6a63114..400354539b 100644
--- a/libudev/libudev-device.c
+++ b/libudev/libudev-device.c
@@ -222,12 +222,11 @@ int udev_device_read_db(struct udev_device *udev_device)
char *next;
target_len = readlink(filename, target, sizeof(target));
- if (target_len > 0)
- target[target_len] = '\0';
- else {
- dbg(udev_device->udev, "error reading db link %s: %m\n", filename);
+ if (target_len <= 0 || target_len == sizeof(target)) {
+ info(udev_device->udev, "error reading db link %s: %m\n", filename);
return -1;
}
+ target[target_len] = '\0';
next = strchr(target, ' ');
if (next != NULL) {
@@ -1095,16 +1094,18 @@ const char *udev_device_get_sysattr_value(struct udev_device *udev_device, const
goto out;
len = readlink(path, target, sizeof(target));
- if (len > 0) {
- target[len] = '\0';
- pos = strrchr(target, '/');
- if (pos != NULL) {
- pos = &pos[1];
- dbg(udev_device->udev, "cache '%s' with link value '%s'\n", sysattr, pos);
- list_entry = udev_list_entry_add(udev_device->udev, &udev_device->sysattr_list, sysattr, pos, 0, 0);
- val = udev_list_entry_get_value(list_entry);
- }
+ if (len <= 0 || len == sizeof(target))
+ goto out;
+ target[len] = '\0';
+
+ pos = strrchr(target, '/');
+ if (pos != NULL) {
+ pos = &pos[1];
+ dbg(udev_device->udev, "cache '%s' with link value '%s'\n", sysattr, pos);
+ list_entry = udev_list_entry_add(udev_device->udev, &udev_device->sysattr_list, sysattr, pos, 0, 0);
+ val = udev_list_entry_get_value(list_entry);
}
+
goto out;
}