summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: df6d9bf)
raw | patch | inline | side by side (parent: df6d9bf)
author | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Fri, 4 Dec 2015 20:03:44 +0000 (21:03 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Sat, 5 Dec 2015 19:40:32 +0000 (20:40 +0100) |
buf2 is initialized to zero, readlink
will write at most sizeof(buf2) -1 bytes,
so the trailing null should not be overwritten.
Coverity doesn't see that, rewrite the code
differently so it does.
CID #38027
Signed-off-by: Florian Forster <octo@collectd.org>
will write at most sizeof(buf2) -1 bytes,
so the trailing null should not be overwritten.
Coverity doesn't see that, rewrite the code
differently so it does.
CID #38027
Signed-off-by: Florian Forster <octo@collectd.org>
src/madwifi.c | patch | blob | history |
diff --git a/src/madwifi.c b/src/madwifi.c
index 13301fffe15aea8afbce76c3ce06105ededfa195..7987378ed4a857e5674080b2d540bfdfbc11b6f6 100644 (file)
--- a/src/madwifi.c
+++ b/src/madwifi.c
if (dev[0] == '.')
return 0;
-
+
ssnprintf (buf, sizeof (buf), "/sys/class/net/%s/device/driver", dev);
- buf[sizeof (buf) - 1] = 0;
+ buf[sizeof (buf) - 1] = '\0';
- memset (buf2, 0, sizeof (buf2));
i = readlink (buf, buf2, sizeof (buf2) - 1);
if (i < 0)
return 0;
+ buf2[i] = '\0';
+
if (strstr (buf2, "/drivers/ath_") == NULL)
return 0;
return 1;