diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2005-04-28 16:15:47 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2005-04-28 16:15:47 +0000 |
commit | a580cf04eb8d1fe6f0ca890282c9088f6b31fbef (patch) | |
tree | bc2f3c9b745fa10407512354d933b995f67c002a /sbin | |
parent | 6e2e6b0ffe1e31a838d9c99fb84ac29d9d8c2b8d (diff) |
Use strlcpy() not snprintf(). OK otto@ and moritz@
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/restore/dirs.c | 14 | ||||
-rw-r--r-- | sbin/restore/interactive.c | 15 |
2 files changed, 17 insertions, 12 deletions
diff --git a/sbin/restore/dirs.c b/sbin/restore/dirs.c index 1ac1b3d1d9f..ee7b71634d6 100644 --- a/sbin/restore/dirs.c +++ b/sbin/restore/dirs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dirs.c,v 1.29 2004/12/30 01:51:32 millert Exp $ */ +/* $OpenBSD: dirs.c,v 1.30 2005/04/28 16:15:45 millert Exp $ */ /* $NetBSD: dirs.c,v 1.26 1997/07/01 05:37:49 lukem Exp $ */ /* @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)dirs.c 8.5 (Berkeley) 8/31/94"; #else -static const char rcsid[] = "$OpenBSD: dirs.c,v 1.29 2004/12/30 01:51:32 millert Exp $"; +static const char rcsid[] = "$OpenBSD: dirs.c,v 1.30 2005/04/28 16:15:45 millert Exp $"; #endif #endif /* not lint */ @@ -225,7 +225,7 @@ treescan(char *pname, ino_t ino, long (*todo)(char *, ino_t, int)) { struct inotab *itp; struct direct *dp; - int namelen; + size_t namelen; long bpt; char locname[MAXPATHLEN + 1]; @@ -246,9 +246,11 @@ treescan(char *pname, ino_t ino, long (*todo)(char *, ino_t, int)) * begin search through the directory * skipping over "." and ".." */ - namelen = snprintf(locname, sizeof(locname), "%s/", pname); - if (namelen >= sizeof(locname)) - namelen = sizeof(locname) - 1; + namelen = strlcpy(locname, pname, sizeof(locname)); + if (namelen >= sizeof(locname) - 1) + namelen = sizeof(locname) - 2; + locname[namelen++] = '/'; + locname[namelen] = '\0'; rst_seekdir(dirp, itp->t_seekpt, itp->t_seekpt); dp = rst_readdir(dirp); /* "." */ if (dp != NULL && strcmp(dp->d_name, ".") == 0) diff --git a/sbin/restore/interactive.c b/sbin/restore/interactive.c index 6503a2e13db..eff96a97f4e 100644 --- a/sbin/restore/interactive.c +++ b/sbin/restore/interactive.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interactive.c,v 1.20 2004/07/17 02:14:33 deraadt Exp $ */ +/* $OpenBSD: interactive.c,v 1.21 2005/04/28 16:15:46 millert Exp $ */ /* $NetBSD: interactive.c,v 1.10 1997/03/19 08:42:52 lukem Exp $ */ /* @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)interactive.c 8.3 (Berkeley) 9/13/94"; #else -static const char rcsid[] = "$OpenBSD: interactive.c,v 1.20 2004/07/17 02:14:33 deraadt Exp $"; +static const char rcsid[] = "$OpenBSD: interactive.c,v 1.21 2005/04/28 16:15:46 millert Exp $"; #endif #endif /* not lint */ @@ -513,7 +513,8 @@ printlist(char *name, char *basename) struct direct *dp; struct afile single; RST_DIR *dirp; - int entries, len, namelen; + size_t namelen; + int entries, len; char locname[MAXPATHLEN]; dp = pathsearch(name); @@ -545,9 +546,11 @@ printlist(char *name, char *basename) fprintf(stderr, "%s:\n", name); entries = 0; listp = list; - namelen = snprintf(locname, sizeof(locname), "%s/", name); - if (namelen >= sizeof(locname)) - namelen = sizeof(locname) - 1; + namelen = strlcpy(locname, name, sizeof(locname)); + if (namelen >= sizeof(locname) - 1) + namelen = sizeof(locname) - 2; + locname[namelen++] = '/'; + locname[namelen] = '\0'; while ((dp = rst_readdir(dirp))) { if (dp == NULL) break; |