From: Antonio Quartulli <a@unstable.cc>
To: The list for a Better Approach To Mobile Ad-hoc Networking
<b.a.t.m.a.n@lists.open-mesh.org>
Subject: Re: [B.A.T.M.A.N.] [PATCH] alfred: Avoid buffer overflow while querying ARP cache
Date: Fri, 27 Jan 2017 22:34:22 +0800 [thread overview]
Message-ID: <20170127143422.GF12187@prodigo.lan> (raw)
In-Reply-To: <20170127141044.5317-1-sven@narfation.org>
[-- Attachment #1: Type: text/plain, Size: 1113 bytes --]
On Fri, Jan 27, 2017 at 03:10:44PM +0100, Sven Eckelmann wrote:
> The arpreq.arp_dev is a limited buffer (16 bytes). Avoid that more bytes
> from the interface name are copied into this buffer by switching from
> strcpy to strncpy.
>
> Fixes: c7da798113a2 ("alfred: IPv4 multicast distribution support.")
> Signed-off-by: Sven Eckelmann <sven@narfation.org>
> ---
> util.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/util.c b/util.c
> index 84ab3af..ed83895 100644
> --- a/util.c
> +++ b/util.c
> @@ -92,7 +92,9 @@ int ipv4_arp_request(struct interface *interface, const alfred_addr *addr,
> sin->sin_family = AF_INET;
> sin->sin_addr.s_addr = addr->ipv4.s_addr;
>
> - strcpy(arpreq.arp_dev, interface->interface);
> + strncpy(arpreq.arp_dev, interface->interface, sizeof(arpreq.arp_dev));
arpreq is already set to 0 few lines above. why not simpling
"sizeof(arpreq.arp_dev) - 1" as last argument for the strncpy() and avoid the
line below?
Or is this required for consistency with the rest of the code?
Cheers,
--
Antonio Quartulli
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
next prev parent reply other threads:[~2017-01-27 14:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-27 14:10 [B.A.T.M.A.N.] [PATCH] alfred: Avoid buffer overflow while querying ARP cache Sven Eckelmann
2017-01-27 14:34 ` Antonio Quartulli [this message]
2017-01-27 20:08 ` Sven Eckelmann
2017-01-30 8:29 ` Simon Wunderlich
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=20170127143422.GF12187@prodigo.lan \
--to=a@unstable.cc \
--cc=b.a.t.m.a.n@lists.open-mesh.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