summaryrefslogtreecommitdiff
path: root/usr.sbin/config
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2002-05-29 09:46:21 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2002-05-29 09:46:21 +0000
commitef1b3f9682539a42c2f5cd67e47ef048adb5f498 (patch)
tree5c884e8d5b01bfdc3d2e97ca2e4359449cce652b /usr.sbin/config
parentb19caa201f0c1b7d209365f918f8322db3d568f1 (diff)
more snprintf
Diffstat (limited to 'usr.sbin/config')
-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
7 files changed, 30 insertions, 24 deletions
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;
}