strncpy -> strlcpy

This commit is contained in:
itojun 2003-05-17 18:51:13 +00:00
parent 3f62dc6d24
commit f35cce81c8
3 changed files with 9 additions and 11 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ac.c,v 1.14 2001/02/19 23:22:40 cgd Exp $ */
/* $NetBSD: ac.c,v 1.15 2003/05/17 18:55:18 itojun Exp $ */
/*
* Copyright (c) 1994 Christopher G. Demetriou
@ -49,7 +49,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: ac.c,v 1.14 2001/02/19 23:22:40 cgd Exp $");
__RCSID("$NetBSD: ac.c,v 1.15 2003/05/17 18:55:18 itojun Exp $");
#endif
#include <sys/types.h>
@ -174,8 +174,7 @@ add_tty(name)
tp->ret = 0;
name++;
}
(void)strncpy(tp->name, name, sizeof (tp->name) - 1);
tp->name[sizeof (tp->name) - 1] = '\0';
(void)strlcpy(tp->name, name, sizeof (tp->name));
if ((rcp = strchr(tp->name, '*')) != NULL) { /* wild card */
*rcp = '\0';
tp->len = strlen(tp->name); /* match len bytes only */
@ -288,8 +287,7 @@ update_user(head, name, secs)
if ((up = NEW(struct user_list)) == NULL)
err(1, "malloc");
up->next = head;
(void)strncpy(up->name, name, sizeof (up->name) - 1);
up->name[sizeof (up->name) - 1] = '\0'; /* paranoid! */
(void)strlcpy(up->name, name, sizeof (up->name));
up->secs = secs;
Total += secs;
return up;

View File

@ -1,4 +1,4 @@
/* $NetBSD: mkdevsw.c,v 1.3 2002/09/06 13:59:09 junyoung Exp $ */
/* $NetBSD: mkdevsw.c,v 1.4 2003/05/17 18:53:01 itojun Exp $ */
/*
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -212,14 +212,14 @@ emitdev(FILE *fp)
if (fputs("\n", fp) < 0)
return (1);
(void)strncpy(mstr, "swap", sizeof(mstr));
(void)strlcpy(mstr, "swap", sizeof(mstr));
if ((dm = ht_lookup(bdevmtab, intern(mstr))) == NULL)
panic("swap device is not configured");
if (fprintf(fp, "const dev_t swapdev = makedev(%d, 0);\n",
dm->dm_bmajor) < 0)
return (1);
(void)strncpy(mstr, "mem", sizeof(mstr));
(void)strlcpy(mstr, "mem", sizeof(mstr));
if ((dm = ht_lookup(cdevmtab, intern(mstr))) == NULL)
panic("memory device is not configured");
if (fprintf(fp, "const dev_t zerodev = makedev(%d, DEV_ZERO);\n",

View File

@ -1,4 +1,4 @@
/* $NetBSD: config.c,v 1.19 2002/07/10 21:13:35 itojun Exp $ */
/* $NetBSD: config.c,v 1.20 2003/05/17 18:51:13 itojun Exp $ */
/* $KAME: config.c,v 1.62 2002/05/29 10:13:10 itojun Exp $ */
/*
@ -138,7 +138,7 @@ getconfig(intface)
tmp->ifindex = tmp->sdl->sdl_index;
} else
tmp->ifindex = if_nametoindex(intface);
strncpy(tmp->ifname, intface, sizeof(tmp->ifname));
strlcpy(tmp->ifname, intface, sizeof(tmp->ifname));
if ((tmp->phymtu = if_getmtu(intface)) == 0) {
tmp->phymtu = IPV6_MMTU;
syslog(LOG_WARNING,