bonding: fix off-by-one error
Subsystems (3)
PATCH 1/1 bonding: fix 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/primary;
--- drivers/net/bonding/bond_sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/bond_sysfs.c +1 -1
@@ -1060,7 +1060,7 @@ static ssize_t bonding_store_primary(struct device *d, goto out; } -sscanf (buf,"%16s" , ifname);/* IFNAMSIZ */ +sscanf (buf,"%15s" , ifname);/* IFNAMSIZ */ /* check to see if we are clearing primary */ if (!strlen (ifname) || buf[0 ] =='\n' ) {
Signature · 1 line
1.7.11.4
PATCH 1/1 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;
Note: Sorry for the second patch but I missed this one while checking
the file. You can squash them into one patch.
--- drivers/net/bonding/bond_sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/bond_sysfs.c +1 -1
@@ -1237,7 +1237,7 @@ static ssize_t bonding_store_active_slave(struct device *d, goto out; } -sscanf (buf,"%16s" , ifname);/* IFNAMSIZ */ +sscanf (buf,"%15s" , ifname);/* IFNAMSIZ */ /* check to see if we are clearing active */ if (!strlen (ifname) || buf[0 ] =='\n' ) {
Signature · 1 line
1.7.11.4
From: Nikolay Aleksandrov <[email protected]>
Date: Wed, 31 Oct 2012 15:42:51 +0100
Quoted 9 lines
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:
withCONFIG_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/primary;Signed-off-by Nikolay Aleksandrov <[email protected]>
I've applied both of your patches, thanks.