diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2002-05-29 09:47:21 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2002-05-29 09:47:21 +0000 |
commit | 0f255ec3ff0a620b4f8064781b438d7cf26407f5 (patch) | |
tree | 1bb9fd29dc494cb1f0a29e53d941403dec213d22 /usr.sbin | |
parent | ef1b3f9682539a42c2f5cd67e47ef048adb5f498 (diff) |
more snprintf
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bad144/bad144.c | 11 | ||||
-rw-r--r-- | usr.sbin/catman/catman.c | 19 | ||||
-rw-r--r-- | usr.sbin/edquota/edquota.c | 10 | ||||
-rw-r--r-- | usr.sbin/grfconfig/grfconfig.c | 6 |
4 files changed, 27 insertions, 19 deletions
diff --git a/usr.sbin/bad144/bad144.c b/usr.sbin/bad144/bad144.c index d7463397f92..2fad8ce27b2 100644 --- a/usr.sbin/bad144/bad144.c +++ b/usr.sbin/bad144/bad144.c @@ -39,7 +39,7 @@ static char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)bad144.c 8.1 (Berkeley) 6/6/93";*/ -static char *rcsid = "$Id: bad144.c,v 1.11 2002/03/14 16:44:24 mpech Exp $"; +static char *rcsid = "$Id: bad144.c,v 1.12 2002/05/29 09:47:20 deraadt Exp $"; #endif /* not lint */ /* @@ -311,7 +311,8 @@ usage: if (nflag == 0 && write(f, (caddr_t)&curbad, sizeof(curbad)) != sizeof(curbad)) { char msg[80]; - (void)sprintf(msg, "bad144: write bad sector file %d", + (void)snprintf(msg, sizeof msg, + "bad144: write bad sector file %d", i/2); perror(msg); } @@ -360,7 +361,8 @@ struct dkbad *bad; printf("Using bad-sector file %d\n", i/2); return(sn); } - (void)sprintf(msg, "bad144: read bad sector file at sn %d", sn); + (void)snprintf(msg, sizeof msg, + "bad144: read bad sector file at sn %d", sn); perror(msg); if (badfile != -1) break; @@ -693,7 +695,8 @@ format(fd, blk) Perror("write format"); if (fop.df_count != fp->f_bufsize) { char msg[80]; - (void)sprintf(msg, "bad144: write format %d", blk); + (void)snprintf(msg, sizeof msg, + "bad144: write format %d", blk); perror(msg); } } diff --git a/usr.sbin/catman/catman.c b/usr.sbin/catman/catman.c index 6c97940b47c..365861616a8 100644 --- a/usr.sbin/catman/catman.c +++ b/usr.sbin/catman/catman.c @@ -29,7 +29,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: catman.c,v 1.3 2002/02/16 21:28:01 millert Exp $"; +static char rcsid[] = "$Id: catman.c,v 1.4 2002/05/29 09:47:20 deraadt Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -152,8 +152,10 @@ catman(path, section) if (sectlen == 0) errx(1, "malformed section string"); - sprintf(mandir, "%s/%s%.*s", path, _PATH_MANPAGES, sectlen, s); - sprintf(catdir, "%s/%s%.*s", path, _PATH_CATPAGES, sectlen, s); + snprintf(mandir, sizeof mandir, "%s/%s%.*s", path, + _PATH_MANPAGES, sectlen, s); + snprintf(catdir, sizeof catdir, "%s/%s%.*s", path, + _PATH_CATPAGES, sectlen, s); if ((dirp = opendir(mandir)) == 0) { warn("can't open %s", mandir); @@ -181,8 +183,10 @@ catman(path, section) strcmp(dp->d_name, "..") == 0) continue; - sprintf(manpage, "%s/%s", mandir, dp->d_name); - sprintf(catpage, "%s/%s", catdir, dp->d_name); + snprintf(manpage, sizeof manpage, "%s/%s", + mandir, dp->d_name); + snprintf(catpage, sizeof catpage, "%s/%s", + catdir, dp->d_name); if ((tmp = strrchr(catpage, '.')) != NULL) strcpy(tmp, ".0"); else @@ -212,7 +216,8 @@ catman(path, section) * manpage is out of date, * reformat */ - sprintf(sysbuf, "nroff -mandoc %s > %s", + snprintf(sysbuf, sizeof sysbuf, + "nroff -mandoc %s > %s", manpage, catpage); if (f_noprint == 0) printf("%s\n", sysbuf); @@ -232,7 +237,7 @@ makewhatis(path) { char sysbuf[1024]; - sprintf(sysbuf, "%s %s", _PATH_MAKEWHATIS, path); + snprintf(sysbuf, sizeof sysbuf, "%s %s", _PATH_MAKEWHATIS, path); if (f_noprint == 0) printf("%s\n", sysbuf); if (f_noaction == 0) diff --git a/usr.sbin/edquota/edquota.c b/usr.sbin/edquota/edquota.c index 74c8ac0bb9f..56e7a38a54b 100644 --- a/usr.sbin/edquota/edquota.c +++ b/usr.sbin/edquota/edquota.c @@ -42,7 +42,7 @@ static char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)edquota.c 8.1 (Berkeley) 6/6/93";*/ -static char *rcsid = "$Id: edquota.c,v 1.31 2002/05/26 09:25:21 deraadt Exp $"; +static char *rcsid = "$Id: edquota.c,v 1.32 2002/05/29 09:47:20 deraadt Exp $"; #endif /* not lint */ /* @@ -674,18 +674,18 @@ cvtstoa(time) if (time % (24 * 60 * 60) == 0) { time /= 24 * 60 * 60; - (void)sprintf(buf, "%d day%s", (int)time, + (void)snprintf(buf, sizeof buf, "%d day%s", (int)time, time == 1 ? "" : "s"); } else if (time % (60 * 60) == 0) { time /= 60 * 60; - (void)sprintf(buf, "%d hour%s", (int)time, + (void)snprintf(buf, sizeof buf, "%d hour%s", (int)time, time == 1 ? "" : "s"); } else if (time % 60 == 0) { time /= 60; - (void)sprintf(buf, "%d minute%s", (int)time, + (void)snprintf(buf, sizeof buf, "%d minute%s", (int)time, time == 1 ? "" : "s"); } else - (void)sprintf(buf, "%d second%s", (int)time, + (void)snprintf(buf, sizeof buf, "%d second%s", (int)time, time == 1 ? "" : "s"); return(buf); } diff --git a/usr.sbin/grfconfig/grfconfig.c b/usr.sbin/grfconfig/grfconfig.c index 479c950a3fa..ee73abeb365 100644 --- a/usr.sbin/grfconfig/grfconfig.c +++ b/usr.sbin/grfconfig/grfconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grfconfig.c,v 1.5 2002/02/16 21:28:02 millert Exp $ */ +/* $OpenBSD: grfconfig.c,v 1.6 2002/05/29 09:47:20 deraadt Exp $ */ /* $NetBSD: grfconfig.c,v 1.6 1997/07/29 23:41:12 veego Exp $ */ /*- @@ -40,7 +40,7 @@ #include <sys/cdefs.h> #ifndef lint -static char rcsid[] = "$OpenBSD: grfconfig.c,v 1.5 2002/02/16 21:28:02 millert Exp $"; +static char rcsid[] = "$OpenBSD: grfconfig.c,v 1.6 2002/05/29 09:47:20 deraadt Exp $"; #endif /* not lint */ #include <sys/file.h> @@ -149,7 +149,7 @@ main(ac, av) continue; *++p = '\0'; - sprintf(obuf, "%s", buf); + snprintf(obuf, sizeof obuf, "%s", buf); lineno = lineno + 1; for (i = 0, *cps = strtok(buf, " \b\t\r\n"); |