readlink does not write a nul character to the end of the
string it returns. Therefore ask for one fewer character
than the buffer size so there's always room for an extra \0.
Signed-off-by: Mathias Nyman <mathias.nyman@nokia.com>
Signed-off-by: Phil Carmody <ext-phil.2.carmody@nokia.com>
Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
int len;
dbg(udev, "found existing symlink '%s'\n", slink);
- len = readlink(slink, buf, sizeof(buf));
+ len = readlink(slink, buf, sizeof(buf) - 1);
if (len > 0) {
buf[len] = '\0';
if (strcmp(target, buf) == 0) {