diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2010-12-09 21:08:19 +0100 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2010-12-10 01:18:14 +0100 |
commit | 8ba13ec1cd00b86001b4344aec11ae0a64395f7b (patch) | |
tree | 0ab102ffa152c4e184e106a34d1a23744e5f44e0 /libudev | |
parent | 329239f506df62df931a063a752dbbb4da0ebb5c (diff) |
libudev: do not overwrite path with readlink() call
Diffstat (limited to 'libudev')
-rw-r--r-- | libudev/libudev-util.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libudev/libudev-util.c b/libudev/libudev-util.c index 030b78cd22..6c309afd05 100644 --- a/libudev/libudev-util.c +++ b/libudev/libudev-util.c @@ -26,15 +26,16 @@ 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]; |