use strlcpy

This commit is contained in:
itojun 2003-05-16 03:56:49 +00:00
parent 4d9a92e2a2
commit 4008ec1218
8 changed files with 52 additions and 39 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_bridge.c,v 1.12 2003/05/14 23:18:29 itojun Exp $ */ /* $NetBSD: if_bridge.c,v 1.13 2003/05/16 04:54:55 itojun Exp $ */
/* /*
* Copyright 2001 Wasabi Systems, Inc. * Copyright 2001 Wasabi Systems, Inc.
@ -82,7 +82,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.12 2003/05/14 23:18:29 itojun Exp $"); __KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.13 2003/05/16 04:54:55 itojun Exp $");
#include "opt_bridge_ipf.h" #include "opt_bridge_ipf.h"
#include "bpfilter.h" #include "bpfilter.h"
@ -760,7 +760,8 @@ bridge_ioctl_gifs(struct bridge_softc *sc, void *arg)
if (len < sizeof(breq)) if (len < sizeof(breq))
break; break;
strcpy(breq.ifbr_ifsname, bif->bif_ifp->if_xname); strlcpy(breq.ifbr_ifsname, bif->bif_ifp->if_xname,
sizeof(breq.ifbr_ifsname));
breq.ifbr_ifsflags = bif->bif_flags; breq.ifbr_ifsflags = bif->bif_flags;
breq.ifbr_state = bif->bif_state; breq.ifbr_state = bif->bif_state;
breq.ifbr_priority = bif->bif_priority; breq.ifbr_priority = bif->bif_priority;
@ -792,7 +793,8 @@ bridge_ioctl_rts(struct bridge_softc *sc, void *arg)
LIST_FOREACH(brt, &sc->sc_rtlist, brt_list) { LIST_FOREACH(brt, &sc->sc_rtlist, brt_list) {
if (len < sizeof(bareq)) if (len < sizeof(bareq))
goto out; goto out;
strcpy(bareq.ifba_ifsname, brt->brt_ifp->if_xname); strlcpy(bareq.ifba_ifsname, brt->brt_ifp->if_xname,
sizeof(bareq.ifba_ifsname));
memcpy(bareq.ifba_dst, brt->brt_addr, sizeof(brt->brt_addr)); memcpy(bareq.ifba_dst, brt->brt_addr, sizeof(brt->brt_addr));
if ((brt->brt_flags & IFBAF_TYPEMASK) == IFBAF_DYNAMIC) if ((brt->brt_flags & IFBAF_TYPEMASK) == IFBAF_DYNAMIC)
bareq.ifba_expire = brt->brt_expire - mono_time.tv_sec; bareq.ifba_expire = brt->brt_expire - mono_time.tv_sec;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ethersubr.c,v 1.107 2003/05/02 03:15:23 itojun Exp $ */ /* $NetBSD: if_ethersubr.c,v 1.108 2003/05/16 04:54:55 itojun Exp $ */
/* /*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -65,7 +65,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.107 2003/05/02 03:15:23 itojun Exp $"); __KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.108 2003/05/16 04:54:55 itojun Exp $");
#include "opt_inet.h" #include "opt_inet.h"
#include "opt_atalk.h" #include "opt_atalk.h"
@ -1093,10 +1093,14 @@ ether_ifattach(struct ifnet *ifp, const u_int8_t *lla)
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
#endif #endif
#ifdef MBUFTRACE #ifdef MBUFTRACE
strcpy(ec->ec_tx_mowner.mo_name, ifp->if_xname); strlcpy(ec->ec_tx_mowner.mo_name, ifp->if_xname,
strcpy(ec->ec_tx_mowner.mo_descr, "tx"); sizeof(ec->ec_tx_mowner.mo_name));
strcpy(ec->ec_rx_mowner.mo_name, ifp->if_xname); strlcpy(ec->ec_tx_mowner.mo_descr, "tx",
strcpy(ec->ec_rx_mowner.mo_descr, "rx"); sizeof(ec->ec_tx_mowner.mo_descr));
strlcpy(ec->ec_rx_mowner.mo_name, ifp->if_xname,
sizeof(ec->ec_rx_mowner.mo_name));
strlcpy(ec->ec_rx_mowner.mo_descr, "rx",
sizeof(ec->ec_rx_mowner.mo_descr));
MOWNER_ATTACH(&ec->ec_tx_mowner); MOWNER_ATTACH(&ec->ec_tx_mowner);
MOWNER_ATTACH(&ec->ec_rx_mowner); MOWNER_ATTACH(&ec->ec_rx_mowner);
ifp->if_mowner = &ec->ec_tx_mowner; ifp->if_mowner = &ec->ec_tx_mowner;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_fddisubr.c,v 1.48 2003/05/14 15:50:51 itojun Exp $ */ /* $NetBSD: if_fddisubr.c,v 1.49 2003/05/16 04:54:55 itojun Exp $ */
/* /*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -69,7 +69,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_fddisubr.c,v 1.48 2003/05/14 15:50:51 itojun Exp $"); __KERNEL_RCSID(0, "$NetBSD: if_fddisubr.c,v 1.49 2003/05/16 04:54:55 itojun Exp $");
#include "opt_inet.h" #include "opt_inet.h"
#include "opt_atalk.h" #include "opt_atalk.h"
@ -839,10 +839,14 @@ fddi_ifattach(ifp, lla)
bpfattach(ifp, DLT_FDDI, sizeof(struct fddi_header)); bpfattach(ifp, DLT_FDDI, sizeof(struct fddi_header));
#endif /* NBPFILTER > 0 */ #endif /* NBPFILTER > 0 */
#ifdef MBUFTRACE #ifdef MBUFTRACE
strcpy(ec->ec_tx_mowner.mo_name, ifp->if_xname); strlcpy(ec->ec_tx_mowner.mo_name, ifp->if_xname,
strcpy(ec->ec_tx_mowner.mo_descr, "tx"); sizeof(ec->ec_tx_mowner.mo_name));
strcpy(ec->ec_rx_mowner.mo_name, ifp->if_xname); strlcpy(ec->ec_tx_mowner.mo_descr, "tx",
strcpy(ec->ec_rx_mowner.mo_descr, "rx"); sizeof(ec->ec_tx_mowner.mo_descr));
strlcpy(ec->ec_rx_mowner.mo_name, ifp->if_xname,
sizeof(ec->ec_rx_mowner.mo_name));
strlcpy(ec->ec_rx_mowner.mo_descr, "rx",
sizeof(ec->ec_rx_mowner.mo_descr));
MOWNER_ATTACH(&ec->ec_tx_mowner); MOWNER_ATTACH(&ec->ec_tx_mowner);
MOWNER_ATTACH(&ec->ec_rx_mowner); MOWNER_ATTACH(&ec->ec_rx_mowner);
ifp->if_mowner = &ec->ec_tx_mowner; ifp->if_mowner = &ec->ec_tx_mowner;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ieee80211subr.c,v 1.32 2003/05/16 01:26:17 dyoung Exp $ */ /* $NetBSD: if_ieee80211subr.c,v 1.33 2003/05/16 04:54:55 itojun Exp $ */
/* $FreeBSD: src/sys/net/if_ieee80211subr.c,v 1.4 2003/01/21 08:55:59 alfred Exp $ */ /* $FreeBSD: src/sys/net/if_ieee80211subr.c,v 1.4 2003/01/21 08:55:59 alfred Exp $ */
/*- /*-
@ -42,7 +42,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_ieee80211subr.c,v 1.32 2003/05/16 01:26:17 dyoung Exp $"); __KERNEL_RCSID(0, "$NetBSD: if_ieee80211subr.c,v 1.33 2003/05/16 04:54:55 itojun Exp $");
#include "opt_inet.h" #include "opt_inet.h"
#include "bpfilter.h" #include "bpfilter.h"
@ -2978,7 +2978,8 @@ ieee80211_cfgget(struct ifnet *ifp, u_long cmd, caddr_t data)
/* nothing appropriate */ /* nothing appropriate */
break; break;
case WI_RID_NODENAME: case WI_RID_NODENAME:
strcpy((char *)&wreq.wi_val[1], hostname); strlcpy((char *)&wreq.wi_val[1], hostname,
sizeof(wreq.wi_val) - 1);
wreq.wi_val[0] = htole16(strlen(hostname)); wreq.wi_val[0] = htole16(strlen(hostname));
wreq.wi_len = (1 + strlen(hostname) + 1) / 2; wreq.wi_len = (1 + strlen(hostname) + 1) / 2;
break; break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_loop.c,v 1.44 2003/05/14 06:47:33 itojun Exp $ */ /* $NetBSD: if_loop.c,v 1.45 2003/05/16 04:54:56 itojun Exp $ */
/* /*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -69,7 +69,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.44 2003/05/14 06:47:33 itojun Exp $"); __KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.45 2003/05/16 04:54:56 itojun Exp $");
#include "opt_inet.h" #include "opt_inet.h"
#include "opt_atalk.h" #include "opt_atalk.h"
@ -179,7 +179,8 @@ loopattach(n)
#endif #endif
#ifdef MBUFTRACE #ifdef MBUFTRACE
ifp->if_mowner = &lomowner[i]; ifp->if_mowner = &lomowner[i];
strcpy(ifp->if_mowner->mo_name, ifp->if_xname); strlcpy(ifp->if_mowner->mo_name, ifp->if_xname,
sizeof(ifp->if_mowner->mo_name));
MOWNER_ATTACH(&lomowner[i]); MOWNER_ATTACH(&lomowner[i]);
#endif #endif
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: rtsock.c,v 1.59 2003/05/02 03:15:25 itojun Exp $ */ /* $NetBSD: rtsock.c,v 1.60 2003/05/16 04:54:56 itojun Exp $ */
/* /*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -65,7 +65,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.59 2003/05/02 03:15:25 itojun Exp $"); __KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.60 2003/05/16 04:54:56 itojun Exp $");
#include "opt_inet.h" #include "opt_inet.h"
@ -849,7 +849,7 @@ rt_ifannouncemsg(ifp, what)
memset(&info, 0, sizeof(info)); memset(&info, 0, sizeof(info));
memset(&ifan, 0, sizeof(ifan)); memset(&ifan, 0, sizeof(ifan));
ifan.ifan_index = ifp->if_index; ifan.ifan_index = ifp->if_index;
strcpy(ifan.ifan_name, ifp->if_xname); strlcpy(ifan.ifan_name, ifp->if_xname, sizeof(ifan.ifan_name));
ifan.ifan_what = what; ifan.ifan_what = what;
m = rt_msg1(RTM_IFANNOUNCE, &info, (caddr_t)&ifan, sizeof(ifan)); m = rt_msg1(RTM_IFANNOUNCE, &info, (caddr_t)&ifan, sizeof(ifan));
if (m == 0) if (m == 0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: tcp_input.c,v 1.164 2003/05/14 06:47:35 itojun Exp $ */ /* $NetBSD: tcp_input.c,v 1.165 2003/05/16 03:58:33 itojun Exp $ */
/* /*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -152,7 +152,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.164 2003/05/14 06:47:35 itojun Exp $"); __KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.165 2003/05/16 03:58:33 itojun Exp $");
#include "opt_inet.h" #include "opt_inet.h"
#include "opt_ipsec.h" #include "opt_ipsec.h"
@ -720,12 +720,12 @@ tcp4_log_refused(ip, th)
char dst[4*sizeof "123"]; char dst[4*sizeof "123"];
if (ip) { if (ip) {
strcpy(src, inet_ntoa(ip->ip_src)); strlcpy(src, inet_ntoa(ip->ip_src), sizeof(src));
strcpy(dst, inet_ntoa(ip->ip_dst)); strlcpy(dst, inet_ntoa(ip->ip_dst), sizeof(dst));
} }
else { else {
strcpy(src, "(unknown)"); strlcpy(src, "(unknown)", sizeof(src));
strcpy(dst, "(unknown)"); strlcpy(dst, "(unknown)", sizeof(dst));
} }
log(LOG_INFO, log(LOG_INFO,
"Connection attempt to TCP %s:%d from %s:%d\n", "Connection attempt to TCP %s:%d from %s:%d\n",
@ -744,12 +744,12 @@ tcp6_log_refused(ip6, th)
char dst[INET6_ADDRSTRLEN]; char dst[INET6_ADDRSTRLEN];
if (ip6) { if (ip6) {
strcpy(src, ip6_sprintf(&ip6->ip6_src)); strlcpy(src, ip6_sprintf(&ip6->ip6_src), sizeof(src));
strcpy(dst, ip6_sprintf(&ip6->ip6_dst)); strlcpy(dst, ip6_sprintf(&ip6->ip6_dst), sizeof(dst));
} }
else { else {
strcpy(src, "(unknown v6)"); strlcpy(src, "(unknown v6)", sizeof(src));
strcpy(dst, "(unknown v6)"); strlcpy(dst, "(unknown v6)", sizeof(dst));
} }
log(LOG_INFO, log(LOG_INFO,
"Connection attempt to TCP [%s]:%d from [%s]:%d\n", "Connection attempt to TCP [%s]:%d from [%s]:%d\n",

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip6_mroute.c,v 1.45 2003/05/15 13:46:15 itojun Exp $ */ /* $NetBSD: ip6_mroute.c,v 1.46 2003/05/16 03:56:49 itojun Exp $ */
/* $KAME: ip6_mroute.c,v 1.49 2001/07/25 09:21:18 jinmei Exp $ */ /* $KAME: ip6_mroute.c,v 1.49 2001/07/25 09:21:18 jinmei Exp $ */
/* /*
@ -85,7 +85,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip6_mroute.c,v 1.45 2003/05/15 13:46:15 itojun Exp $"); __KERNEL_RCSID(0, "$NetBSD: ip6_mroute.c,v 1.46 2003/05/16 03:56:49 itojun Exp $");
#include "opt_inet.h" #include "opt_inet.h"
@ -586,8 +586,9 @@ add_m6if(mifcp)
if (mifcp->mif6c_flags & MIFF_REGISTER) { if (mifcp->mif6c_flags & MIFF_REGISTER) {
if (reg_mif_num == (mifi_t)-1) { if (reg_mif_num == (mifi_t)-1) {
strcpy(multicast_register_if.if_xname, strlcpy(multicast_register_if.if_xname,
"register_mif"); /* XXX */ "register_mif",
sizeof(multicast_register_if.if_xname));
multicast_register_if.if_flags |= IFF_LOOPBACK; multicast_register_if.if_flags |= IFF_LOOPBACK;
multicast_register_if.if_index = mifcp->mif6c_mifi; multicast_register_if.if_index = mifcp->mif6c_mifi;
reg_mif_num = mifcp->mif6c_mifi; reg_mif_num = mifcp->mif6c_mifi;