From 4c4f98d0595ffa11558eea21a6d304a78cafef76 Mon Sep 17 00:00:00 2001 From: Neil Kettle Date: Sun, 29 Mar 2026 21:57:40 +0200 Subject: [PATCH] Fix comparison/buffer size calculation in snprintf calls Fixes an obviously incorrect comparison checking the return value from socket(). Also, some bad arithmetic in the snprintf for ifb name (needs looking at! don't quite know what you intend here) otherwise for certain values of 'len' your reading a negative offset. Signed-off-by: Neil Kettle --- interface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface.c b/interface.c index 837cb95..31d6f19 100644 --- a/interface.c +++ b/interface.c @@ -199,7 +199,7 @@ interface_ifb_name(struct qosify_iface *iface) ifname[4] = iface->ifname[0]; ifname[5] = iface->ifname[1]; - snprintf(ifname + 6, IFNAMSIZ - 6, "%s", iface->ifname + len - (IFNAMSIZ + 6) - 1); + snprintf(ifname + 6, IFNAMSIZ - 6, "%s", iface->ifname + len - (IFNAMSIZ - 6) - 1); return ifname; } @@ -627,7 +627,7 @@ int qosify_iface_init(void) int fd, opt; socket_fd = socket(AF_UNIX, SOCK_DGRAM, 0); - if (socket < 0) + if (socket_fd < 0) return -1; rtnl_sock = nl_socket_alloc();