From 317e5932836ec040ccf3a19054a922eb7f00bd0a Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Sun, 16 Aug 2009 09:13:31 +0200 Subject: [PATCH] madwifi plugin: Fix buffer handling around `readlink'. readlink(2) doesn't null-terminate the buffer in any case. Thanks to Ondrej for pointing this out. --- src/madwifi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/madwifi.c b/src/madwifi.c index 9d973ec0..f0230f9b 100644 --- a/src/madwifi.c +++ b/src/madwifi.c @@ -769,8 +769,8 @@ process_device (int sk, const char *dev) static int check_devname (const char *dev) { - char buf[256]; - char buf2[256]; + char buf[PATH_MAX]; + char buf2[PATH_MAX]; int i; if (dev[0] == '.') @@ -779,10 +779,10 @@ check_devname (const char *dev) ssnprintf (buf, sizeof (buf), "/sys/class/net/%s/device/driver", dev); buf[sizeof (buf) - 1] = 0; + memset (buf2, 0, sizeof (buf2)); i = readlink (buf, buf2, sizeof (buf2) - 1); if (i < 0) return 0; - buf2[sizeof (buf2) - 1] = 0; if (strstr (buf2, "/drivers/ath_") == NULL) return 0; -- 2.30.2