Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bonding: fix second off-by-one error

Fix off-by-one error because IFNAMSIZ == 16 and when this
code gets executed we stick a NULL byte where we should not.

How to reproduce:
with CONFIG_CC_STACKPROTECTOR=y (otherwise it may pass by silently)
modprobe bonding; echo 1 > /sys/class/net/bond0/bonding/mode;
echo "AAAAAAAAAAAAAAAA" > /sys/class/net/bond0/bonding/active_slave;

Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>

Note: Sorry for the second patch but I missed this one while checking
the file. You can squash them into one patch.
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

nikolay@redhat.com and committed by
David S. Miller
c84e1590 eb6e98a1

+1 -1
+1 -1
drivers/net/bonding/bond_sysfs.c
··· 1237 1237 goto out; 1238 1238 } 1239 1239 1240 - sscanf(buf, "%16s", ifname); /* IFNAMSIZ */ 1240 + sscanf(buf, "%15s", ifname); /* IFNAMSIZ */ 1241 1241 1242 1242 /* check to see if we are clearing active */ 1243 1243 if (!strlen(ifname) || buf[0] == '\n') {