summaryrefslogtreecommitdiff
path: root/system-linux.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2022-11-17 09:09:09 +0100
committerJo-Philipp Wich <jo@mein.io>2022-11-17 09:13:49 +0100
commit2cffe0c44e62b9e063fa30ce07431753494c53c2 (patch)
tree4f9977485780402f699ddeb95e76ea6654b684fb /system-linux.c
parent76d2d41b7355e02f95fbfa79affbd232fb090595 (diff)
downloadnetifd-2cffe0c44e62b9e063fa30ce07431753494c53c2.tar.gz
treewide: correctly apply IFNAMSIZ limit
The `IFNAMSIZ` macro defines the required buffer size to hold a Linux interface name including the terminating zero byte while netifd currently uses an `IFNAMSIZ + 1` limit for interface name buffers. This causes netifd to use overlong names (16 instead of 15 bytes) in netlink communication with the kernel, leading to netlink failure replies due to policy violations. Fix this issue by applying the correct length, that is `IFNAMSIZ` directly, to the corresponding buffers. Ref: https://github.com/openwrt/openwrt/issues/11259 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'system-linux.c')
-rw-r--r--system-linux.c2
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);