summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/bad144/bad144.c11
-rw-r--r--usr.sbin/catman/catman.c19
-rw-r--r--usr.sbin/config/main.c6
-rw-r--r--usr.sbin/config/mkheaders.c6
-rw-r--r--usr.sbin/config/mkioconf.c7
-rw-r--r--usr.sbin/config/mkmakefile.c14
-rw-r--r--usr.sbin/config/mkswap.c9
-rw-r--r--usr.sbin/config/sem.c10
-rw-r--r--usr.sbin/config/strerror.c2
-rw-r--r--usr.sbin/edquota/edquota.c10
-rw-r--r--usr.sbin/grfconfig/grfconfig.c6
-rw-r--r--usr.sbin/usbdevs/usbdevs.c4
-rw-r--r--usr.sbin/videomode/videomode.c3
13 files changed, 61 insertions, 46 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/config/main.c b/usr.sbin/config/main.c
index 8c99e5655bc..fd50958f460 100644
--- a/usr.sbin/config/main.c
+++ b/usr.sbin/config/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.25 2002/03/14 16:44:24 mpech Exp $ */
+/* $OpenBSD: main.c,v 1.26 2002/05/29 09:45:39 deraadt Exp $ */
/* $NetBSD: main.c,v 1.22 1997/02/02 21:12:33 thorpej Exp $ */
/*
@@ -286,7 +286,7 @@ mksymlinks()
char *p, buf[MAXPATHLEN];
const char *q;
- sprintf(buf, "arch/%s/include", machine);
+ snprintf(buf, sizeof buf, "arch/%s/include", machine);
p = sourcepath(buf);
(void)unlink("machine");
ret = symlink(p, "machine");
@@ -295,7 +295,7 @@ mksymlinks()
p, strerror(errno));
if (machinearch != NULL) {
- sprintf(buf, "arch/%s/include", machinearch);
+ snprintf(buf, sizeof buf, "arch/%s/include", machinearch);
p = sourcepath(buf);
q = machinearch;
} else {
diff --git a/usr.sbin/config/mkheaders.c b/usr.sbin/config/mkheaders.c
index 376e4baac25..8d067d0f999 100644
--- a/usr.sbin/config/mkheaders.c
+++ b/usr.sbin/config/mkheaders.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mkheaders.c,v 1.12 2002/03/14 16:44:24 mpech Exp $ */
+/* $OpenBSD: mkheaders.c,v 1.13 2002/05/29 09:45:39 deraadt Exp $ */
/* $NetBSD: mkheaders.c,v 1.12 1997/02/02 21:12:34 thorpej Exp $ */
/*
@@ -93,7 +93,7 @@ emitcnt(head)
char buf[BUFSIZ];
char fname[BUFSIZ];
- (void)sprintf(fname, "%s.h", head->nv_name);
+ (void)snprintf(fname, sizeof fname, "%s.h", head->nv_name);
if ((fp = fopen(fname, "r")) == NULL)
goto writeit;
nv = head;
@@ -153,7 +153,7 @@ emitopt(nv)
/*
* Compare the new file to the old.
*/
- sprintf(fname, "opt_%s.h", nv->nv_name);
+ snprintf(fname, sizeof fname, "opt_%s.h", nv->nv_name);
if ((fp = fopen(fname, "r")) == NULL)
goto writeit;
nlines = 0;
diff --git a/usr.sbin/config/mkioconf.c b/usr.sbin/config/mkioconf.c
index f9820531396..6d4192e8faa 100644
--- a/usr.sbin/config/mkioconf.c
+++ b/usr.sbin/config/mkioconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mkioconf.c,v 1.19 2002/03/14 16:44:24 mpech Exp $ */
+/* $OpenBSD: mkioconf.c,v 1.20 2002/05/29 09:45:39 deraadt Exp $ */
/* $NetBSD: mkioconf.c,v 1.41 1996/11/11 14:18:49 mycroft Exp $ */
/*
@@ -127,7 +127,7 @@ emithdr(ofp)
* ioconf.c, from \"%s\"\n\
*/\n\n", conffile) < 0)
return (1);
- (void)sprintf(ifn, "ioconf.incl.%s", machine);
+ (void)snprintf(ifn, sizeof ifn, "ioconf.incl.%s", machine);
if ((ifp = fopen(ifn, "r")) != NULL) {
while ((n = fread(buf, 1, sizeof(buf), ifp)) > 0)
if (fwrite(buf, 1, n, ofp) != n)
@@ -405,7 +405,8 @@ struct cfdata cfdata[] = {\n\
vs = "";
v = 0;
if (i->i_locoff >= 0) {
- (void)sprintf(locbuf, "loc+%3d", i->i_locoff);
+ (void)snprintf(locbuf, sizeof locbuf, "loc+%3d",
+ i->i_locoff);
loc = locbuf;
} else
loc = "loc";
diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c
index 505d7d10969..9dae18ecf50 100644
--- a/usr.sbin/config/mkmakefile.c
+++ b/usr.sbin/config/mkmakefile.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mkmakefile.c,v 1.11 2002/03/14 16:44:24 mpech Exp $ */
+/* $OpenBSD: mkmakefile.c,v 1.12 2002/05/29 09:45:39 deraadt Exp $ */
/* $NetBSD: mkmakefile.c,v 1.34 1997/02/02 21:12:36 thorpej Exp $ */
/*
@@ -78,7 +78,8 @@ mkmakefile()
char *ifname;
char line[BUFSIZ], buf[200];
- (void)sprintf(buf, "arch/%s/conf/Makefile.%s", machine, machine);
+ (void)snprintf(buf, sizeof buf, "arch/%s/conf/Makefile.%s",
+ machine, machine);
ifname = sourcepath(buf);
if ((ifp = fopen(ifname, "r")) == NULL) {
(void)fprintf(stderr, "config: cannot read %s: %s\n",
@@ -330,12 +331,12 @@ emitfiles(fp, suffix)
if (suffix == 'c') {
for (cf = allcf; cf != NULL; cf = cf->cf_next) {
if (cf->cf_root == NULL)
- (void)sprintf(swapname,
+ (void)snprintf(swapname, sizeof swapname,
"$S/arch/%s/%s/swapgeneric.c",
machine, machine);
else
- (void)sprintf(swapname, "./swap%s.c",
- cf->cf_name);
+ (void)snprintf(swapname, sizeof swapname,
+ "./swap%s.c", cf->cf_name);
len = strlen(swapname);
if (lpos + len > 72) {
if (fputs(" \\\n", fp) < 0)
@@ -379,7 +380,8 @@ emitrules(fp)
ch = fpath[strlen(fpath) - 1];
if (islower(ch))
ch = toupper(ch);
- (void)sprintf(buf, "${%s_%c}", cp, ch);
+ (void)snprintf(buf, sizeof buf, "${%s_%c}",
+ cp, ch);
cp = buf;
}
if (fprintf(fp, "\t%s\n\n", cp) < 0)
diff --git a/usr.sbin/config/mkswap.c b/usr.sbin/config/mkswap.c
index 67de13c4ca4..11398fe6ec6 100644
--- a/usr.sbin/config/mkswap.c
+++ b/usr.sbin/config/mkswap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mkswap.c,v 1.9 2002/03/14 16:44:24 mpech Exp $ */
+/* $OpenBSD: mkswap.c,v 1.10 2002/05/29 09:45:39 deraadt Exp $ */
/* $NetBSD: mkswap.c,v 1.5 1996/08/31 20:58:27 mycroft Exp $ */
/*
@@ -76,9 +76,10 @@ dev_t d;
static char buf[32];
if (d == NODEV)
- (void)sprintf(buf, "NODEV");
+ (void)snprintf(buf, sizeof buf, "NODEV");
else
- (void)sprintf(buf, "makedev(%d, %d)", major(d), minor(d));
+ (void)snprintf(buf, sizeof buf, "makedev(%d, %d)",
+ major(d), minor(d));
return buf;
}
@@ -91,7 +92,7 @@ mkoneswap(cf)
char fname[200];
char *mountroot;
- (void)sprintf(fname, "swap%s.c", cf->cf_name);
+ (void)snprintf(fname, sizeof fname, "swap%s.c", cf->cf_name);
if ((fp = fopen(fname, "w")) == NULL) {
(void)fprintf(stderr, "config: cannot write %s: %s\n",
fname, strerror(errno));
diff --git a/usr.sbin/config/sem.c b/usr.sbin/config/sem.c
index cabbb8f6caf..bf0528633d7 100644
--- a/usr.sbin/config/sem.c
+++ b/usr.sbin/config/sem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sem.c,v 1.25 2002/03/14 16:44:24 mpech Exp $ */
+/* $OpenBSD: sem.c,v 1.26 2002/05/29 09:45:39 deraadt Exp $ */
/* $NetBSD: sem.c,v 1.10 1996/11/11 23:40:11 gwr Exp $ */
/*
@@ -578,10 +578,12 @@ resolve(nvp, name, what, dflt, part)
if (dev->d_major == maj)
break;
if (dev == NULL)
- (void)sprintf(buf, "<%d/%d>", maj, min);
+ (void)snprintf(buf, sizeof buf, "<%d/%d>",
+ maj, min);
else
- (void)sprintf(buf, "%s%d%c", dev->d_name,
- min / maxpartitions, (min % maxpartitions) + 'a');
+ (void)snprintf(buf, sizeof buf, "%s%d%c",
+ dev->d_name, min / maxpartitions,
+ (min % maxpartitions) + 'a');
nv->nv_str = intern(buf);
return (0);
}
diff --git a/usr.sbin/config/strerror.c b/usr.sbin/config/strerror.c
index 2d3eb60068b..72cf0d6fbef 100644
--- a/usr.sbin/config/strerror.c
+++ b/usr.sbin/config/strerror.c
@@ -14,6 +14,6 @@ char *strerror(en)
if ((0 <= en) && (en < sys_nerr))
return sys_errlist[en];
- sprintf(errmsg, "Error %d", en);
+ snprintf(errmsg, sizeof errmsg, "Error %d", en);
return errmsg;
}
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");
diff --git a/usr.sbin/usbdevs/usbdevs.c b/usr.sbin/usbdevs/usbdevs.c
index a22f1576e4f..ecce9a5ebfc 100644
--- a/usr.sbin/usbdevs/usbdevs.c
+++ b/usr.sbin/usbdevs/usbdevs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: usbdevs.c,v 1.5 2002/05/10 00:09:17 nate Exp $ */
+/* $OpenBSD: usbdevs.c,v 1.6 2002/05/29 09:46:20 deraadt Exp $ */
/* $NetBSD: usbdevs.c,v 1.19 2002/02/21 00:34:31 christos Exp $ */
/*
@@ -205,7 +205,7 @@ main(int argc, char **argv)
if (dev == 0) {
for (ncont = 0, i = 0; i < 10; i++) {
- sprintf(buf, "%s%d", USBDEV, i);
+ snprintf(buf, sizeof buf, "%s%d", USBDEV, i);
f = open(buf, O_RDONLY);
if (f >= 0) {
dumpone(buf, f, addr);
diff --git a/usr.sbin/videomode/videomode.c b/usr.sbin/videomode/videomode.c
index 9dfcf165b18..797f62c78f5 100644
--- a/usr.sbin/videomode/videomode.c
+++ b/usr.sbin/videomode/videomode.c
@@ -101,7 +101,8 @@ get_grf()
errx(1, "stdin not a tty");
if (major(stb.st_rdev) != 13)
errx(1, "stdin not an ite device");
- (void)sprintf(grfname, "/dev/grf%d", minor(stb.st_rdev) & 0x7);
+ (void)snprintf(grfname, sizeof grfname, "/dev/grf%d",
+ minor(stb.st_rdev) & 0x7);
if ((grffd = open(grfname, 2)) < 0)
err(1, "%s", grfname);
return (grffd);