diff options
author | Stijn Tintel <stijn@linux-ipv6.be> | 2022-12-08 00:57:08 +0200 |
---|---|---|
committer | Stijn Tintel <stijn@linux-ipv6.be> | 2022-12-08 00:57:08 +0200 |
commit | 02ada7a28b9390625d29aad6308f623df930342a (patch) | |
tree | 7a508b08ad81c5976343c7685a1c700ee8e395fd /system-linux.c | |
parent | 86586994c97ca99d2da57224575d4a28760725e2 (diff) | |
download | netifd-staging/stintel/ifnamsiz.tar.gz |
treewide: fix use of IFNAMSIZstaging/stintel/ifnamsiz
IFNAMSIZ already includes an extra byte for the null character
terminating the string. Adding an extra byte can cause the interface
name to be truncated, resulting in undefined behaviour.
Drop the extra byte. For the bonding case, the interface name written to
sysfs should be prefixed with + or - so we do need an extra byte.
Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
Diffstat (limited to 'system-linux.c')
-rw-r--r-- | system-linux.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/system-linux.c b/system-linux.c index 0f13a99..9fe869f 100644 --- a/system-linux.c +++ b/system-linux.c @@ -1030,7 +1030,7 @@ int system_bonding_set_port(struct device *dev, struct device *port, bool add, b { const char *port_name = port->ifname; const char op_ch = add ? '+' : '-'; - char buf[IFNAMSIZ + 2]; + char buf[IFNAMSIZ + 1]; snprintf(buf, sizeof(buf), "%c%s", op_ch, port_name); system_if_down(port); |