mirror of
https://github.com/systemd/systemd.git
synced 2025-01-26 14:04:03 +03:00
remove buffer-overrun risk in readlink call
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>
This commit is contained in:
parent
c51d2f2746
commit
e925018786
@ -163,7 +163,7 @@ 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));
|
||||
len = readlink(slink, buf, sizeof(buf) - 1);
|
||||
if (len > 0) {
|
||||
buf[len] = '\0';
|
||||
if (strcmp(target, buf) == 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user