From 1ca82f4e49c421a8a018bc3dcba8b7860ac541e7 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Tue, 30 Apr 2019 16:59:28 +0200 Subject: [PATCH] monitor: Fix length parameter of strncpy for kernel names --- monitor/main.c | 2 +- monitor/nlmon.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/monitor/main.c b/monitor/main.c index 594eb938..7c36c95f 100644 --- a/monitor/main.c +++ b/monitor/main.c @@ -101,7 +101,7 @@ static void genl_parse(uint16_t type, const void *data, uint32_t len, id = *((uint16_t *) NLA_DATA(nla)); break; case CTRL_ATTR_FAMILY_NAME: - strncpy(name, NLA_DATA(nla), GENL_NAMSIZ); + strncpy(name, NLA_DATA(nla), GENL_NAMSIZ - 1); break; } } diff --git a/monitor/nlmon.c b/monitor/nlmon.c index 6a1edc8b..fc5664d0 100644 --- a/monitor/nlmon.c +++ b/monitor/nlmon.c @@ -4322,7 +4322,7 @@ static void genl_ctrl(struct nlmon *nlmon, const void *data, uint32_t len) id = *((uint16_t *) NLA_DATA(nla)); break; case CTRL_ATTR_FAMILY_NAME: - strncpy(name, NLA_DATA(nla), GENL_NAMSIZ); + strncpy(name, NLA_DATA(nla), GENL_NAMSIZ - 1); break; } } @@ -5055,7 +5055,7 @@ static struct l_io *open_packet(const char *name) return NULL; } - strncpy(ifr.ifr_name, name, IFNAMSIZ); + strncpy(ifr.ifr_name, name, IFNAMSIZ - 1); if (ioctl(fd, SIOCGIFINDEX, &ifr) < 0) { perror("Failed to get monitor index");