summaryrefslogtreecommitdiff
path: root/udev
diff options
context:
space:
mode:
authorMathias Nyman <mathias.nyman@nokia.com>2010-04-21 13:52:52 +0300
committerMartin Pitt <martin.pitt@ubuntu.com>2010-04-21 13:41:14 +0200
commite925018786d85fb3aed3b62a0a89309f9a7d5e4f (patch)
tree9c892c1012241c61d354bb39d28c1c1588a38184 /udev
parentc51d2f2746a54c8418965f22d1882b1ac3a18ed8 (diff)
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>
Diffstat (limited to 'udev')
-rw-r--r--udev/udev-node.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/udev/udev-node.c b/udev/udev-node.c
index 2a2c2cf0b4..ceb1d52ea7 100644
--- a/udev/udev-node.c
+++ b/udev/udev-node.c
@@ -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) {