From: Helge Deller <deller@gmx.de>
To: Simon Horman <horms@verge.net.au>, kexec@lists.infradead.org
Cc: Sven Schnelle <svens@stackframe.org>
Subject: [PATCH]kexec-tools: Fix possible out-of-bounds access in ifdown
Date: Tue, 1 Oct 2019 17:06:05 +0200 [thread overview]
Message-ID: <20191001150605.GA25636@ls3530.fritz.box> (raw)
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
next reply other threads:[~2019-10-01 15:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-01 15:06 Helge Deller [this message]
2019-10-03 8:14 ` [PATCH]kexec-tools: Fix possible out-of-bounds access in ifdown Simon Horman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191001150605.GA25636@ls3530.fritz.box \
--to=deller@gmx.de \
--cc=horms@verge.net.au \
--cc=kexec@lists.infradead.org \
--cc=svens@stackframe.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox