summaryrefslogtreecommitdiff
path: root/udev
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 /udev
parente925018786d85fb3aed3b62a0a89309f9a7d5e4f (diff)
more readlink buffer size handling
Diffstat (limited to 'udev')
-rw-r--r--udev/udev-node.c4
-rw-r--r--udev/udev-watch.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/udev/udev-node.c b/udev/udev-node.c
index ceb1d52ea7..5c1b04b86c 100644
--- a/udev/udev-node.c
+++ b/udev/udev-node.c
@@ -163,8 +163,8 @@ static int node_symlink(struct udev *udev, const char *node, const char *slink)
int len;
dbg(udev, "found existing symlink '%s'\n", slink);
- len = readlink(slink, buf, sizeof(buf) - 1);
- if (len > 0) {
+ len = readlink(slink, buf, sizeof(buf));
+ if (len > 0 && len < (int)sizeof(buf)) {
buf[len] = '\0';
if (strcmp(target, buf) == 0) {
info(udev, "preserve already existing symlink '%s' to '%s'\n",
diff --git a/udev/udev-watch.c b/udev/udev-watch.c
index 7135d9f472..5fa60101c4 100644
--- a/udev/udev-watch.c
+++ b/udev/udev-watch.c
@@ -81,7 +81,7 @@ void udev_watch_restore(struct udev *udev)
s = device;
l = util_strpcpy(&s, sizeof(device), udev_get_sys_path(udev));
len = readlinkat(dirfd(dir), ent->d_name, s, l);
- if (len <= 0 || len >= (ssize_t)l)
+ if (len <= 0 || len == (ssize_t)l)
goto unlink;
s[len] = '\0';
@@ -173,7 +173,7 @@ struct udev_device *udev_watch_lookup(struct udev *udev, int wd)
s = majmin;
l = util_strpcpy(&s, sizeof(majmin), udev_get_sys_path(udev));
len = readlink(filename, s, l);
- if (len < 0 || (size_t)len >= l)
+ if (len <= 0 || (size_t)len == l)
return NULL;
s[len] = '\0';