use bounded string op

This commit is contained in:
itojun 2003-07-13 08:05:58 +00:00
parent b5bc655b98
commit 8883e1fb40
8 changed files with 37 additions and 36 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: dir.c,v 1.9 2003/04/02 10:39:27 fvdl Exp $ */
/* $NetBSD: dir.c,v 1.10 2003/07/13 08:13:19 itojun Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@ -292,7 +292,7 @@ fileerror(ino_t cwd, ino_t ino, char *errmesg)
pwarn("%s ", errmesg);
pinode(ino);
printf("\n");
getpathname(pathbuf, cwd, ino);
getpathname(pathbuf, sizeof(pathbuf), cwd, ino);
if (ino < ROOTINO || ino >= maxino) {
pfatal("NAME=%s\n", pathbuf);
return;
@ -533,7 +533,7 @@ makeentry(ino_t parent, ino_t ino, char *name)
}
if ((ckinode(dp, &idesc) & ALTERED) != 0)
return (1);
getpathname(pathbuf, parent, parent);
getpathname(pathbuf, sizeof(pathbuf), parent, parent);
vp = vget(fs, parent);
dp = VTOD(vp);
if (expanddir(vp, dp, pathbuf) == 0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: extern.h,v 1.5 2003/04/02 10:39:27 fvdl Exp $ */
/* $NetBSD: extern.h,v 1.6 2003/07/13 08:13:19 itojun Exp $ */
/*
* Copyright (c) 1994 James A. Jegers
@ -48,7 +48,7 @@ void freeblk(daddr_t, long);
void freeino(ino_t);
void freeinodebuf(void);
int ftypeok(struct ufs1_dinode *);
void getpathname(char *, ino_t, ino_t);
void getpathname(char *, size_t, ino_t, ino_t);
void inocleanup(void);
void inodirty(struct inode *);
int linkup(ino_t, ino_t);

View File

@ -1,4 +1,4 @@
/* $NetBSD: inode.c,v 1.18 2003/07/12 16:13:38 yamt Exp $ */
/* $NetBSD: inode.c,v 1.19 2003/07/13 08:13:19 itojun Exp $ */
/*
* Copyright (c) 1997, 1998
@ -137,8 +137,8 @@ ckinode(struct ufs1_dinode *dp, struct inodesc *idesc)
if (*ap == 0) {
if (idesc->id_type == DATA && ndb >= 0) {
/* An empty block in a directory XXX */
getpathname(pathbuf, idesc->id_number,
idesc->id_number);
getpathname(pathbuf, sizeof(pathbuf),
idesc->id_number, idesc->id_number);
pfatal("DIRECTORY %s: CONTAINS EMPTY BLOCKS",
pathbuf);
if (reply("ADJUST LENGTH") == 1) {
@ -176,8 +176,8 @@ ckinode(struct ufs1_dinode *dp, struct inodesc *idesc)
} else {
if (idesc->id_type == DATA && remsize > 0) {
/* An empty block in a directory XXX */
getpathname(pathbuf, idesc->id_number,
idesc->id_number);
getpathname(pathbuf, sizeof(pathbuf),
idesc->id_number, idesc->id_number);
pfatal("DIRECTORY %s: CONTAINS EMPTY BLOCKS",
pathbuf);
if (reply("ADJUST LENGTH") == 1) {
@ -260,8 +260,8 @@ iblock(struct inodesc *idesc, long ilevel, u_int64_t isize)
} else {
if (idesc->id_type == DATA && isize > 0) {
/* An empty block in a directory XXX */
getpathname(pathbuf, idesc->id_number,
idesc->id_number);
getpathname(pathbuf, sizeof(pathbuf),
idesc->id_number, idesc->id_number);
pfatal("DIRECTORY %s: CONTAINS EMPTY BLOCKS",
pathbuf);
if (reply("ADJUST LENGTH") == 1) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: pass2.c,v 1.8 2003/04/02 10:39:28 fvdl Exp $ */
/* $NetBSD: pass2.c,v 1.9 2003/07/13 08:13:19 itojun Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@ -145,7 +145,8 @@ pass2()
inodirty(VTOI(vp));
}
} else if ((inp->i_isize & (DIRBLKSIZ - 1)) != 0) {
getpathname(pathbuf, inp->i_number, inp->i_number);
getpathname(pathbuf, sizeof(pathbuf), inp->i_number,
inp->i_number);
pwarn("DIRECTORY %s: LENGTH %lu NOT MULTIPLE OF %d",
pathbuf, (unsigned long) inp->i_isize, DIRBLKSIZ);
if (preen)
@ -237,7 +238,7 @@ pass2check(struct inodesc * idesc)
proto.d_ino = idesc->id_number;
proto.d_type = DT_DIR;
proto.d_namlen = 1;
(void) strcpy(proto.d_name, ".");
(void) strlcpy(proto.d_name, ".", sizeof(proto.d_name));
entrysize = DIRSIZ(0, &proto, 0);
if (dirp->d_ino != 0 && strcmp(dirp->d_name, "..") != 0) {
pfatal("CANNOT FIX, FIRST ENTRY IN DIRECTORY CONTAINS %s\n",
@ -268,7 +269,7 @@ chk1:
proto.d_ino = inp->i_parent;
proto.d_type = DT_DIR;
proto.d_namlen = 2;
(void) strcpy(proto.d_name, "..");
(void) strlcpy(proto.d_name, "..", sizeof(proto.d_name));
entrysize = DIRSIZ(0, &proto, 0);
if (idesc->id_entryno == 0) {
n = DIRSIZ(0, dirp, 0);
@ -393,9 +394,10 @@ again:
case DFOUND:
inp = getinoinfo(dirp->d_ino);
if (inp->i_parent != 0 && idesc->id_entryno > 2) {
getpathname(pathbuf, idesc->id_number,
idesc->id_number);
getpathname(namebuf, dirp->d_ino, dirp->d_ino);
getpathname(pathbuf, sizeof(pathbuf),
idesc->id_number, idesc->id_number);
getpathname(namebuf, sizeof(namebuf),
dirp->d_ino, dirp->d_ino);
pwarn("%s %s %s\n", pathbuf,
"IS AN EXTRANEOUS HARD LINK TO DIRECTORY",
namebuf);

View File

@ -1,4 +1,4 @@
/* $NetBSD: utilities.c,v 1.13 2003/04/02 10:39:28 fvdl Exp $ */
/* $NetBSD: utilities.c,v 1.14 2003/07/13 08:13:19 itojun Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@ -186,7 +186,7 @@ freeblk(daddr_t blkno, long frags)
* Find a pathname
*/
void
getpathname(char *namebuf, ino_t curdir, ino_t ino)
getpathname(char *namebuf, size_t namebuflen, ino_t curdir, ino_t ino)
{
int len;
register char *cp;
@ -194,12 +194,12 @@ getpathname(char *namebuf, ino_t curdir, ino_t ino)
static int busy = 0;
if (curdir == ino && ino == ROOTINO) {
(void) strcpy(namebuf, "/");
(void) strlcpy(namebuf, "/", namebuflen);
return;
}
if (busy ||
(statemap[curdir] != DSTATE && statemap[curdir] != DFOUND)) {
(void) strcpy(namebuf, "?");
(void) strlcpy(namebuf, "?", namebuflen);
return;
}
busy = 1;

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount_nfs.c,v 1.42 2003/05/16 15:33:45 yamt Exp $ */
/* $NetBSD: mount_nfs.c,v 1.43 2003/07/13 08:08:12 itojun Exp $ */
/*
* Copyright (c) 1992, 1993, 1994
@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\n\
#if 0
static char sccsid[] = "@(#)mount_nfs.c 8.11 (Berkeley) 5/4/95";
#else
__RCSID("$NetBSD: mount_nfs.c,v 1.42 2003/05/16 15:33:45 yamt Exp $");
__RCSID("$NetBSD: mount_nfs.c,v 1.43 2003/07/13 08:08:12 itojun Exp $");
#endif
#endif /* not lint */
@ -246,7 +246,7 @@ mount_nfs(argc, argv)
last_ruid = -1;
if (krb_get_lrealm(realm, 0) != KSUCCESS)
(void)strcpy(realm, KRB_REALM);
(void)strlcpy(realm, KRB_REALM, sizeof(realm));
if (sizeof (struct nfsrpc_nickverf) != RPCX_NICKVERF ||
sizeof (struct nfsrpc_fullblock) != RPCX_FULLBLOCK ||
((char *)&ktick.kt) - ((char *)&ktick) != NFSX_UNSIGNED ||
@ -336,8 +336,7 @@ mount_nfs(argc, argv)
break;
#ifdef NFSKERB
case 'm':
(void)strncpy(realm, optarg, REALM_SZ - 1);
realm[REALM_SZ - 1] = '\0';
(void)strlcpy(realm, optarg, sizeof(realm));
break;
#endif
case 'o':

View File

@ -1,4 +1,4 @@
/* $NetBSD: newfs.c,v 1.65 2003/04/02 20:48:13 dbj Exp $ */
/* $NetBSD: newfs.c,v 1.66 2003/07/13 08:06:38 itojun Exp $ */
/*
* Copyright (c) 2002 Networks Associates Technology, Inc.
@ -52,7 +52,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1989, 1993, 1994\n\
#if 0
static char sccsid[] = "@(#)newfs.c 8.13 (Berkeley) 5/1/95";
#else
__RCSID("$NetBSD: newfs.c,v 1.65 2003/04/02 20:48:13 dbj Exp $");
__RCSID("$NetBSD: newfs.c,v 1.66 2003/07/13 08:06:38 itojun Exp $");
#endif
#endif /* not lint */
@ -753,7 +753,7 @@ rewritelabel(char *s, volatile int fd, struct disklabel *lp)
/*
* Make name for 'c' partition.
*/
strcpy(specname, s);
strlcpy(specname, s, sizeof(specname));
cp = specname + strlen(specname) - 1;
if (!isdigit(*cp))
*cp = 'c';

View File

@ -1,4 +1,4 @@
/* $NetBSD: wdogctl.c,v 1.8 2003/06/23 11:53:45 agc Exp $ */
/* $NetBSD: wdogctl.c,v 1.9 2003/07/13 08:05:58 itojun Exp $ */
/*-
* Copyright (c) 2000 Zembu Labs, Inc.
@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: wdogctl.c,v 1.8 2003/06/23 11:53:45 agc Exp $");
__RCSID("$NetBSD: wdogctl.c,v 1.9 2003/07/13 08:05:58 itojun Exp $");
#endif
@ -139,7 +139,7 @@ enable_kernel(const char *name, u_int period)
if (strlen(name) >= WDOG_NAMESIZE)
errx(1, "invalid watchdog timer name: %s", name);
strcpy(wm.wm_name, name);
strlcpy(wm.wm_name, name, sizeof(wm.wm_name));
wm.wm_mode = WDOG_MODE_KTICKLE;
wm.wm_period = period;
@ -164,7 +164,7 @@ enable_user(const char *name, u_int period)
if (strlen(name) >= WDOG_NAMESIZE)
errx(1, "invalid watchdog timer name: %s", name);
strcpy(wm.wm_name, name);
strlcpy(wm.wm_name, name, sizeof(wm.wm_name));
wm.wm_mode = WDOG_MODE_UTICKLE;
wm.wm_period = period;
@ -321,7 +321,7 @@ list_timers(void)
printf("Available watchdog timers:\n");
for (i = 0, cp = buf; i < count; i++, cp += WDOG_NAMESIZE) {
cp[WDOG_NAMESIZE - 1] = '\0';
strcpy(wm.wm_name, cp);
strlcpy(wm.wm_name, cp, sizeof(wm.wm_name));
if (ioctl(fd, WDOGIOC_GMODE, &wm) == -1)
wm.wm_mode = -1;