summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2002-05-30 07:36:45 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2002-05-30 07:36:45 +0000
commit0f62153ff22c58ff246e73db9768f9eac5dc1bc0 (patch)
tree99de4ff19cc127b9177e3c02a4c8af7239c2ae73
parentfbc3641e11aa4c7650b1951a473b7a5eadd38958 (diff)
snprintf in .y files
-rw-r--r--usr.bin/rdist/gram.y9
-rw-r--r--usr.sbin/config/gram.y16
-rw-r--r--usr.sbin/mrouted/cfparse.y4
3 files changed, 17 insertions, 12 deletions
diff --git a/usr.bin/rdist/gram.y b/usr.bin/rdist/gram.y
index 9c813740aa7..6109f75e68a 100644
--- a/usr.bin/rdist/gram.y
+++ b/usr.bin/rdist/gram.y
@@ -1,5 +1,5 @@
%{
-/* $OpenBSD: gram.y,v 1.4 1998/06/26 21:21:11 millert Exp $ */
+/* $OpenBSD: gram.y,v 1.5 2002/05/30 07:36:44 deraadt Exp $ */
/*
* Copyright (c) 1993 Michael A. Cooper
@@ -41,7 +41,7 @@ static char RCSid[] =
"$From: gram.y,v 6.29 1994/04/11 23:59:15 mcooper Exp mcooper $";
#else
static char RCSid[] =
-"$OpenBSD: gram.y,v 1.4 1998/06/26 21:21:11 millert Exp $";
+"$OpenBSD: gram.y,v 1.5 2002/05/30 07:36:44 deraadt Exp $";
#endif
static char *sccsid = "@(#)gram.y 5.2 (Berkeley) 85/06/21";
@@ -351,7 +351,7 @@ again:
switch (yytext[1]) {
case 'o':
if (parsedistopts(&yytext[2], &opt, TRUE)) {
- (void) sprintf(ebuf,
+ (void) snprintf(ebuf, sizeof ebuf,
"Bad distfile options \"%s\".",
&yytext[2]);
yyerror(ebuf);
@@ -376,7 +376,8 @@ again:
case 'r': opt = DO_NODESCEND; break;
default:
- (void) sprintf(ebuf, "Unknown option \"%s\".", yytext);
+ (void) snprintf(ebuf, sizeof ebuf,
+ "Unknown option \"%s\".", yytext);
yyerror(ebuf);
}
diff --git a/usr.sbin/config/gram.y b/usr.sbin/config/gram.y
index 3427fc593b2..f0f7dc5831b 100644
--- a/usr.sbin/config/gram.y
+++ b/usr.sbin/config/gram.y
@@ -1,5 +1,5 @@
%{
-/* $OpenBSD: gram.y,v 1.13 2002/05/29 18:39:00 deraadt Exp $ */
+/* $OpenBSD: gram.y,v 1.14 2002/05/30 07:36:44 deraadt Exp $ */
/* $NetBSD: gram.y,v 1.14 1997/02/02 21:12:32 thorpej Exp $ */
/*
@@ -286,9 +286,13 @@ locdefault:
value:
WORD { $$ = $1; } |
EMPTY { $$ = $1; } |
- signed_number { char bf[40];
- (void)sprintf(bf, FORMAT($1), $1);
- $$ = intern(bf); };
+ signed_number {
+ char bf[40];
+
+ (void)snprintf(bf, sizeof bf,
+ FORMAT($1), $1);
+ $$ = intern(bf);
+ };
signed_number:
NUMBER { $$ = $1; } |
@@ -449,12 +453,12 @@ setmachine(mch, mcharch)
machine = mch;
machinearch = mcharch;
- (void)sprintf(buf, "arch/%s/conf/files.%s", machine, machine);
+ (void)snprintf(buf, sizeof buf, "arch/%s/conf/files.%s", machine, machine);
if (include(buf, ENDFILE) != 0)
exit(1);
if (machinearch != NULL)
- (void)sprintf(buf, "arch/%s/conf/files.%s",
+ (void)snprintf(buf, sizeof buf, "arch/%s/conf/files.%s",
machinearch, machinearch);
else
strlcpy(buf, _PATH_DEVNULL, sizeof buf);
diff --git a/usr.sbin/mrouted/cfparse.y b/usr.sbin/mrouted/cfparse.y
index bb805e25acc..47dc14510d5 100644
--- a/usr.sbin/mrouted/cfparse.y
+++ b/usr.sbin/mrouted/cfparse.y
@@ -398,7 +398,7 @@ fatal(char *fmt, ...)
char buf[200];
va_start(ap, fmt);
- vsprintf(buf, fmt, ap);
+ vsnprintf(buf, sizeof buf, fmt, ap);
va_end(ap);
log(LOG_ERR,0,"%s: %s near line %d", configfilename, buf, lineno);
@@ -411,7 +411,7 @@ warn(char *fmt, ...)
char buf[200];
va_start(ap, fmt);
- vsprintf(buf, fmt, ap);
+ vsnprintf(buf, sizeof buf, fmt, ap);
va_end(ap);
log(LOG_WARNING,0,"%s: %s near line %d", configfilename, buf, lineno);