CID 980057, 980058, use strlcpy()

This commit is contained in:
christos 2016-04-24 16:59:15 +00:00
parent 1202244b0e
commit 107dc46d92
2 changed files with 9 additions and 10 deletions

View File

@ -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 @@ pppoe_dispatch_disc_pkt(struct mbuf *m, int off)
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 @@ pppoe_dispatch_disc_pkt(struct mbuf *m, int off)
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 @@ pppoe_ioctl(struct ifnet *ifp, unsigned long cmd, void *data)
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;

View File

@ -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 @@ sppp_params(struct sppp *sp, u_long cmd, void *data)
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;