diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2003-04-17 06:48:48 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2003-04-17 06:48:48 +0000 |
commit | 4cd6648a36f1b4b79f494afafabd8d0f46ff8163 (patch) | |
tree | ed5cfcc9d37b00e36c4759cfc1fb2b35c64b21c2 | |
parent | 3a57158f9512bec738ab0e68dbd1c2093b989cc2 (diff) |
strings. mostly from deraadt@, some from tdeval@ and myself
-rw-r--r-- | sbin/fsck_ext2fs/dir.c | 6 | ||||
-rw-r--r-- | sbin/fsck_ext2fs/extern.h | 4 | ||||
-rw-r--r-- | sbin/fsck_ext2fs/inode.c | 14 | ||||
-rw-r--r-- | sbin/fsck_ext2fs/pass2.c | 17 | ||||
-rw-r--r-- | sbin/fsck_ext2fs/preen.c | 8 | ||||
-rw-r--r-- | sbin/fsck_ext2fs/utilities.c | 21 |
6 files changed, 35 insertions, 35 deletions
diff --git a/sbin/fsck_ext2fs/dir.c b/sbin/fsck_ext2fs/dir.c index b1c23d59e73..9fc3dabf219 100644 --- a/sbin/fsck_ext2fs/dir.c +++ b/sbin/fsck_ext2fs/dir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dir.c,v 1.8 2002/06/09 08:13:05 todd Exp $ */ +/* $OpenBSD: dir.c,v 1.9 2003/04/17 06:48:47 tedu Exp $ */ /* $NetBSD: dir.c,v 1.5 2000/01/28 16:01:46 bouyer Exp $ */ /* @@ -272,7 +272,7 @@ fileerror(cwd, ino, errmesg) pwarn("%s ", errmesg); pinode(ino); printf("\n"); - getpathname(pathbuf, cwd, ino); + getpathname(pathbuf, sizeof pathbuf, cwd, ino); if ((ino < EXT2_FIRSTINO && ino != EXT2_ROOTINO) || ino > maxino) { pfatal("NAME=%s\n", pathbuf); return; @@ -521,7 +521,7 @@ makeentry(parent, ino, name) } if ((ckinode(dp, &idesc) & ALTERED) != 0) return (1); - getpathname(pathbuf, parent, parent); + getpathname(pathbuf, sizeof pathbuf, parent, parent); dp = ginode(parent); if (expanddir(dp, pathbuf) == 0) return (0); diff --git a/sbin/fsck_ext2fs/extern.h b/sbin/fsck_ext2fs/extern.h index 782d63f269b..82f4f70f855 100644 --- a/sbin/fsck_ext2fs/extern.h +++ b/sbin/fsck_ext2fs/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.4 2002/02/16 21:27:34 millert Exp $ */ +/* $OpenBSD: extern.h,v 1.5 2003/04/17 06:48:47 tedu Exp $ */ /* $NetBSD: extern.h,v 1.1 1997/06/11 11:21:46 bouyer Exp $ */ /* @@ -52,7 +52,7 @@ void freeblk(daddr_t); void freeino(ino_t); void freeinodebuf(void); int ftypeok(struct ext2fs_dinode *); -void getpathname(char *, ino_t, ino_t); +void getpathname(char *, size_t, ino_t, ino_t); void inocleanup(void); void inodirty(void); int linkup(ino_t, ino_t); diff --git a/sbin/fsck_ext2fs/inode.c b/sbin/fsck_ext2fs/inode.c index d699bd6094b..f3919511f31 100644 --- a/sbin/fsck_ext2fs/inode.c +++ b/sbin/fsck_ext2fs/inode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inode.c,v 1.10 2002/06/09 08:13:05 todd Exp $ */ +/* $OpenBSD: inode.c,v 1.11 2003/04/17 06:48:47 tedu Exp $ */ /* $NetBSD: inode.c,v 1.8 2000/01/28 16:01:46 bouyer Exp $ */ /* @@ -95,8 +95,8 @@ ckinode(dp, 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) { @@ -131,8 +131,8 @@ ckinode(dp, 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) { @@ -214,8 +214,8 @@ iblock(idesc, ilevel, 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) { diff --git a/sbin/fsck_ext2fs/pass2.c b/sbin/fsck_ext2fs/pass2.c index 77bdfb54d97..4a191051186 100644 --- a/sbin/fsck_ext2fs/pass2.c +++ b/sbin/fsck_ext2fs/pass2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass2.c,v 1.7 2002/06/09 08:13:05 todd Exp $ */ +/* $OpenBSD: pass2.c,v 1.8 2003/04/17 06:48:47 tedu Exp $ */ /* $NetBSD: pass2.c,v 1.6 2000/01/28 16:01:46 bouyer Exp $ */ /* @@ -135,7 +135,8 @@ pass2() inodirty(); } } else if ((inp->i_isize & (sblock.e2fs_bsize - 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, (u_long)inp->i_isize, sblock.e2fs_bsize); if (preen) @@ -234,7 +235,7 @@ pass2check(idesc) proto.e2d_type = EXT2_FT_DIR; else proto.e2d_type = 0; - (void)strcpy(proto.e2d_name, "."); + (void)strlcpy(proto.e2d_name, ".", sizeof proto.e2d_name); entrysize = EXT2FS_DIRSIZ(proto.e2d_namlen); if (fs2h32(dirp->e2d_ino) != 0 && strcmp(dirp->e2d_name, "..") != 0) { pfatal("CANNOT FIX, FIRST ENTRY IN DIRECTORY CONTAINS %s\n", @@ -269,7 +270,7 @@ chk1: proto.e2d_type = EXT2_FT_DIR; else proto.e2d_type = 0; - (void)strcpy(proto.e2d_name, ".."); + (void)strlcpy(proto.e2d_name, "..", sizeof proto.e2d_name); entrysize = EXT2FS_DIRSIZ(2); if (idesc->id_entryno == 0) { n = EXT2FS_DIRSIZ(dirp->e2d_namlen); @@ -386,10 +387,10 @@ again: case DFOUND: inp = getinoinfo(fs2h32(dirp->e2d_ino)); if (inp->i_parent != 0 && idesc->id_entryno > 2) { - getpathname(pathbuf, idesc->id_number, - idesc->id_number); - getpathname(namebuf, fs2h32(dirp->e2d_ino), - fs2h32(dirp->e2d_ino)); + getpathname(pathbuf, sizeof pathbuf, + idesc->id_number, idesc->id_number); + getpathname(namebuf, sizeof namebuf, + fs2h32(dirp->e2d_ino), fs2h32(dirp->e2d_ino)); pwarn("%s %s %s\n", pathbuf, "IS AN EXTRANEOUS HARD LINK TO DIRECTORY", namebuf); diff --git a/sbin/fsck_ext2fs/preen.c b/sbin/fsck_ext2fs/preen.c index d058bd20870..f3fbf19c54c 100644 --- a/sbin/fsck_ext2fs/preen.c +++ b/sbin/fsck_ext2fs/preen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: preen.c,v 1.8 2003/04/06 08:51:24 avsm Exp $ */ +/* $OpenBSD: preen.c,v 1.9 2003/04/17 06:48:47 tedu Exp $ */ /* $NetBSD: preen.c,v 1.2 1997/09/14 14:27:30 lukem Exp $ */ /* @@ -248,16 +248,14 @@ addpart(name, fsname, auxdata) exit (8); } pt = *ppt; - if ((pt->name = malloc(strlen(name) + 1)) == NULL) { + if ((pt->name = strdup(name)) == NULL) { fprintf(stderr, "out of memory"); exit (8); } - (void)strcpy(pt->name, name); - if ((pt->fsname = malloc(strlen(fsname) + 1)) == NULL) { + if ((pt->fsname = strdup(fsname)) == NULL) { fprintf(stderr, "out of memory"); exit (8); } - (void)strcpy(pt->fsname, fsname); pt->next = NULL; pt->auxdata = auxdata; } diff --git a/sbin/fsck_ext2fs/utilities.c b/sbin/fsck_ext2fs/utilities.c index b14837c2b05..be16b70b744 100644 --- a/sbin/fsck_ext2fs/utilities.c +++ b/sbin/fsck_ext2fs/utilities.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utilities.c,v 1.11 2002/02/23 21:23:46 deraadt Exp $ */ +/* $OpenBSD: utilities.c,v 1.12 2003/04/17 06:48:47 tedu Exp $ */ /* $NetBSD: utilities.c,v 1.6 2001/02/04 21:19:34 christos Exp $ */ /* @@ -397,29 +397,30 @@ freeblk(blkno) * Find a pathname */ void -getpathname(namebuf, curdir, ino) +getpathname(namebuf, buflen, curdir, ino) char *namebuf; + size_t buflen; ino_t curdir, ino; { - int len; + size_t len; char *cp; struct inodesc idesc; static int busy = 0; if (curdir == ino && ino == EXT2_ROOTINO) { - (void)strcpy(namebuf, "/"); + (void)strlcpy(namebuf, "/", buflen); return; } if (busy || (statemap[curdir] != DSTATE && statemap[curdir] != DFOUND)) { - (void)strcpy(namebuf, "?"); + (void)strlcpy(namebuf, "?", buflen); return; } busy = 1; memset(&idesc, 0, sizeof(struct inodesc)); idesc.id_type = DATA; idesc.id_fix = IGNORE; - cp = &namebuf[MAXPATHLEN - 1]; + cp = &namebuf[buflen - 1]; *cp = '\0'; if (curdir != ino) { idesc.id_parent = curdir; @@ -440,16 +441,16 @@ getpathname(namebuf, curdir, ino) break; len = strlen(namebuf); cp -= len; - memcpy(cp, namebuf, (size_t)len); - *--cp = '/'; + memcpy(cp, namebuf, len); + *(--cp) = '/'; if (cp < &namebuf[EXT2FS_MAXNAMLEN]) break; ino = idesc.id_number; } busy = 0; if (ino != EXT2_ROOTINO) - *--cp = '?'; - memcpy(namebuf, cp, (size_t)(&namebuf[MAXPATHLEN] - cp)); + *(--cp) = '?'; + memcpy(namebuf, cp, (size_t)(&namebuf[buflen] - cp)); } void |