diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2002-05-31 22:49:30 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2002-05-31 22:49:30 +0000 |
commit | 3bf3f327b9636a77c99320f0ae74f9f67516edd4 (patch) | |
tree | b7fe9b70ea56a6ca4033c9559ad82f77019d60d4 /usr.bin/lex/misc.c | |
parent | 5fcf4bea9d3d83fd91071bdbe9449083ed0b61de (diff) |
recommit strlcpy/snprintf diff after i found my bug
Diffstat (limited to 'usr.bin/lex/misc.c')
-rw-r--r-- | usr.bin/lex/misc.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/usr.bin/lex/misc.c b/usr.bin/lex/misc.c index 146ff823212..2952b4c086d 100644 --- a/usr.bin/lex/misc.c +++ b/usr.bin/lex/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.8 2002/05/31 00:56:21 deraadt Exp $ */ +/* $OpenBSD: misc.c,v 1.9 2002/05/31 22:49:29 deraadt Exp $ */ /* misc - miscellaneous flex routines */ @@ -28,7 +28,7 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -/* $Header: /cvs/OpenBSD/src/usr.bin/lex/misc.c,v 1.8 2002/05/31 00:56:21 deraadt Exp $ */ +/* $Header: /cvs/OpenBSD/src/usr.bin/lex/misc.c,v 1.9 2002/05/31 22:49:29 deraadt Exp $ */ #include "flexdef.h" @@ -46,7 +46,7 @@ int value; return; } - sprintf( buf, "#define %s %d\n", defname, value ); + snprintf( buf, sizeof buf, "#define %s %d\n", defname, value ); add_action( buf ); } @@ -364,7 +364,7 @@ const char msg[]; int arg; { char errmsg[MAXLINE]; - (void) sprintf( errmsg, msg, arg ); + (void) snprintf( errmsg, sizeof errmsg, msg, arg ); flexerror( errmsg ); } @@ -376,7 +376,7 @@ const char msg[], arg[]; { char errmsg[MAXLINE]; - (void) sprintf( errmsg, msg, arg ); + (void) snprintf( errmsg, sizeof errmsg, msg, arg ); flexerror( errmsg ); } @@ -414,14 +414,16 @@ int do_infile; *s2 = '\0'; if ( do_infile ) - sprintf( directive, line_fmt, linenum, filename ); + snprintf( directive, sizeof directive, line_fmt, + linenum, filename ); else { if ( output_file == stdout ) /* Account for the line directive itself. */ ++out_linenum; - sprintf( directive, line_fmt, out_linenum, filename ); + snprintf( directive, sizeof directive, line_fmt, + out_linenum, filename ); } /* If output_file is nil then we should put the directive in @@ -733,8 +735,8 @@ int c; #endif default: - (void) sprintf( rform, "\\%.3o", - (unsigned int) c ); + (void) snprintf( rform, sizeof rform, + "\\%.3o", (unsigned int) c ); return rform; } } |