fix a potential off-by-on eerror inside udevtrigegr
authorJohn Crispin <blogic@openwrt.org>
Mon, 23 Nov 2015 09:31:23 +0000 (10:31 +0100)
committerJohn Crispin <blogic@openwrt.org>
Fri, 27 Nov 2015 16:48:47 +0000 (17:48 +0100)
coverity found this: 1330086

Signed-off-by: John Crispin <blogic@openwrt.org>
plug/udevtrigger.c

index 5013189530a1741b8bfd8f3c9db85085124477f8..3eba19a681e2edee1989dfc4fc35ca85f2f9d1f6 100644 (file)
@@ -114,7 +114,7 @@ static int sysfs_resolve_link(char *devpath, size_t size)
 
        strlcpy(link_path, "/sys", sizeof(link_path));
        strlcat(link_path, devpath, sizeof(link_path));
-       len = readlink(link_path, link_target, sizeof(link_target));
+       len = readlink(link_path, link_target, sizeof(link_target) - 1);
        if (len <= 0)
                return -1;
        link_target[len] = '\0';