Source-Changes-HG archive

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

[src/trunk]: src/sys/net CID 980057, 980058, use strlcpy()



details:   https://anonhg.NetBSD.org/src/rev/6f226356fa18
branches:  trunk
changeset: 344854:6f226356fa18
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Apr 24 16:59:15 2016 +0000

description:
CID 980057, 980058, use strlcpy()

diffstat:

 sys/net/if_pppoe.c    |  13 ++++++-------
 sys/net/if_spppsubr.c |   6 +++---
 2 files changed, 9 insertions(+), 10 deletions(-)

diffs (78 lines):

diff -r 00ff839e952c -r 6f226356fa18 sys/net/if_pppoe.c
--- a/sys/net/if_pppoe.c        Sun Apr 24 15:11:26 2016 +0000
+++ b/sys/net/if_pppoe.c        Sun Apr 24 16:59:15 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_pppoe.c,v 1.105 2016/04/15 01:31:29 ozaki-r Exp $ */
+/* $NetBSD: if_pppoe.c,v 1.106 2016/04/24 16:59:15 christos Exp $ */
 
 /*-
  * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.105 2016/04/15 01:31:29 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.106 2016/04/24 16:59:15 christos Exp $");
 
 #include "pppoe.h"
 
@@ -485,10 +485,9 @@
                                        n = m_pulldown(m, off + sizeof(*pt),
                                            len, &noff);
                                        if (n) {
-                                               strncpy(error,
+                                               strlcpy(error,
                                                    mtod(n, char*) + noff,
                                                    len);
-                                               error[len] = '\0';
                                        }
                                        printf("%s: connected to %s\n",
                                            devname, error);
@@ -560,9 +559,8 @@
                                n = m_pulldown(m, off + sizeof(*pt), len,
                                    &noff);
                                if (n && error) {
-                                       strncpy(error, 
+                                       strlcpy(error, 
                                            mtod(n, char *) + noff, len);
-                                       error[len] = '\0';
                                }
                        }
                        if (error) {
@@ -949,7 +947,8 @@
                struct pppoediscparms *parms = (struct pppoediscparms*)data;
                memset(parms, 0, sizeof *parms);
                if (sc->sc_eth_if)
-                       strncpy(parms->ifname, sc->sc_eth_if->if_xname, IFNAMSIZ);
+                       strlcpy(parms->ifname, sc->sc_eth_if->if_xname,
+                           sizeof(parms->ifname));
                return 0;
        }
        break;
diff -r 00ff839e952c -r 6f226356fa18 sys/net/if_spppsubr.c
--- a/sys/net/if_spppsubr.c     Sun Apr 24 15:11:26 2016 +0000
+++ b/sys/net/if_spppsubr.c     Sun Apr 24 16:59:15 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_spppsubr.c,v 1.137 2016/04/23 12:15:38 martin Exp $  */
+/*     $NetBSD: if_spppsubr.c,v 1.138 2016/04/24 16:59:15 christos Exp $        */
 
 /*
  * Synchronous PPP/Cisco link level subroutines.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.137 2016/04/23 12:15:38 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.138 2016/04/24 16:59:15 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -5070,7 +5070,7 @@
 
                cfg->myauthflags = sp->myauth.flags;
                cfg->hisauthflags = sp->hisauth.flags;
-               strncpy(cfg->ifname, sp->pp_if.if_xname, IFNAMSIZ);
+               strlcpy(cfg->ifname, sp->pp_if.if_xname, sizeof(cfg->ifname));
                cfg->hisauth = 0;
                if (sp->hisauth.proto)
                    cfg->hisauth = (sp->hisauth.proto == PPP_PAP) ? SPPP_AUTHPROTO_PAP : SPPP_AUTHPROTO_CHAP;



Home | Main Index | Thread Index | Old Index