Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/dhcpcd/dist CID 1102787: Only copy the interfac...



details:   https://anonhg.NetBSD.org/src/rev/e0e7acb0227b
branches:  trunk
changeset: 791357:e0e7acb0227b
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Nov 14 04:24:33 2013 +0000

description:
CID 1102787: Only copy the interface name if it is NUL terminated, avoiding
a buffer overrun by one in the equals case.

diffstat:

 external/bsd/dhcpcd/dist/if-options.c |  7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diffs (22 lines):

diff -r 55804cb20e3e -r e0e7acb0227b external/bsd/dhcpcd/dist/if-options.c
--- a/external/bsd/dhcpcd/dist/if-options.c     Thu Nov 14 04:00:48 2013 +0000
+++ b/external/bsd/dhcpcd/dist/if-options.c     Thu Nov 14 04:24:33 2013 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: if-options.c,v 1.1.1.21 2013/09/20 10:51:29 roy Exp $");
+ __RCSID("$NetBSD: if-options.c,v 1.2 2013/11/14 04:24:33 christos Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -1168,9 +1168,8 @@
                        if (ifo->ia_type == 0)
                                ifo->ia_type = D6_OPTION_IA_NA;
                        ifo->iaid_len = strlen(ifname);
-                       if (ifo->iaid_len <= sizeof(ifo->iaid->iaid)) {
-                               strncpy((char *)ifo->iaid->iaid, ifname,
-                                       sizeof(ifo->iaid->iaid));
+                       if (ifo->iaid_len < sizeof(ifo->iaid->iaid)) {
+                               memcpy(ifo->iaid->iaid, ifname, len);
                                memset(ifo->iaid->iaid + ifo->iaid_len, 0,
                                        sizeof(ifo->iaid->iaid) -ifo->iaid_len);
                        } else {



Home | Main Index | Thread Index | Old Index