chiark / gitweb /
more readlink buffer size handling
[elogind.git] / udev / udev-node.c
index ceb1d52ea7f7bf2c794696b057018ad5fd5e68d4..5c1b04b86c88bb150899c8c8e46d121379538c04 100644 (file)
@@ -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",