Make sure the resutl from readlink is properly null terminated
authorJouni Malinen <j@w1.fi>
Sat, 16 Jan 2010 15:19:06 +0000 (17:19 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 16 Jan 2010 15:19:06 +0000 (17:19 +0200)
src/drivers/linux_ioctl.c

index f806167..0d6cf54 100644 (file)
@@ -186,7 +186,8 @@ int linux_br_get(char *brname, const char *ifname)
        char path[128], brlink[128], *pos;
        os_snprintf(path, sizeof(path), "/sys/class/net/%s/brport/bridge",
                    ifname);
-       if (readlink(path, brlink, sizeof(brlink)) < 0)
+       os_memset(brlink, 0, sizeof(brlink));
+       if (readlink(path, brlink, sizeof(brlink) - 1) < 0)
                return -1;
        pos = os_strrchr(brlink, '/');
        if (pos == NULL)