]> err.no Git - systemd/commitdiff
libudev: do not overwrite path with readlink() call
authorKay Sievers <kay.sievers@vrfy.org>
Thu, 9 Dec 2010 20:08:19 +0000 (21:08 +0100)
committerKay Sievers <kay.sievers@vrfy.org>
Fri, 10 Dec 2010 00:18:14 +0000 (01:18 +0100)
libudev/libudev-util.c

index 030b78cd224382ff8c2de359b541c766a579443f..6c309afd0536798fe3a1e81dffb2b68d4bb7a591 100644 (file)
 static ssize_t get_sys_link(struct udev *udev, const char *slink, const char *syspath, char *value, size_t size)
 {
        char path[UTIL_PATH_SIZE];
+       char target[UTIL_PATH_SIZE];
        ssize_t len;
        const char *pos;
 
        util_strscpyl(path, sizeof(path), syspath, "/", slink, NULL);
-       len = readlink(path, path, sizeof(path));
-       if (len <= 0 || len == (ssize_t)sizeof(path))
+       len = readlink(path, target, sizeof(target));
+       if (len <= 0 || len == (ssize_t)sizeof(target))
                return -1;
-       path[len] = '\0';
-       pos = strrchr(path, '/');
+       target[len] = '\0';
+       pos = strrchr(target, '/');
        if (pos == NULL)
                return -1;
        pos = &pos[1];