]> err.no Git - systemd/commitdiff
util_resolve_sys_link(): fix possible buffer overflow
authorFlorian Zumbiehl <florz@florz.de>
Tue, 1 Sep 2009 10:38:16 +0000 (12:38 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Tue, 1 Sep 2009 10:38:16 +0000 (12:38 +0200)
libudev/libudev-util.c

index dcc4a0fd16e78e9270a352f13da947c4d60d0e90..61cd963421a4842db897318b0aa83537ef29aac5 100644 (file)
@@ -56,13 +56,13 @@ int util_resolve_sys_link(struct udev *udev, char *syspath, size_t size)
 {
        char link_target[UTIL_PATH_SIZE];
 
-       int len;
+       ssize_t len;
        int i;
        int back;
        char *base;
 
        len = readlink(syspath, link_target, sizeof(link_target));
-       if (len <= 0)
+       if (len <= 0 || len == (ssize_t)sizeof(link_target))
                return -1;
        link_target[len] = '\0';
        dbg(udev, "path link '%s' points to '%s'\n", syspath, link_target);