* [PATCH]kexec-tools: Fix possible out-of-bounds access in ifdown
@ 2019-10-01 15:06 Helge Deller
2019-10-03 8:14 ` Simon Horman
0 siblings, 1 reply; 2+ messages in thread
From: Helge Deller @ 2019-10-01 15:06 UTC (permalink / raw)
To: Simon Horman, kexec; +Cc: Sven Schnelle
Fix a possible out-of-bounds access in function ifdown():
ifdown.c: In function 'ifdown':
ifdown.c:56:4: warning: 'strncpy' specified bound 16 equals destination size [-Wstringop-truncation]
56 | strncpy(ifr.ifr_name, ifp->if_name, IFNAMSIZ);
Signed-off-by: Helge Deller <deller@gmx.de>
diff --git a/kexec/ifdown.c b/kexec/ifdown.c
index 9679ad7..3ac19c1 100644
--- a/kexec/ifdown.c
+++ b/kexec/ifdown.c
@@ -53,7 +53,8 @@ int ifdown(void)
if (strchr(ifp->if_name, ':') != NULL)
continue;
- strncpy(ifr.ifr_name, ifp->if_name, IFNAMSIZ);
+ strncpy(ifr.ifr_name, ifp->if_name, IFNAMSIZ-1);
+ ifr.ifr_name[IFNAMSIZ-1] = 0;
if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
fprintf(stderr, "ifdown: shutdown ");
perror(ifp->if_name);
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-10-03 8:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-01 15:06 [PATCH]kexec-tools: Fix possible out-of-bounds access in ifdown Helge Deller
2019-10-03 8:14 ` Simon Horman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox