sprintf->snprintf paranoia

Obtained from: OpenBSD (?)
This commit is contained in:
Warner Losh 1997-12-24 19:39:57 +00:00
parent 45b3189258
commit d83662583c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=31978

View File

@ -36,7 +36,7 @@
static char sccsid[] = "@(#)print.c 8.1 (Berkeley) 6/4/93";
#endif
static const char rcsid[] =
"$Id$";
"$Id: print.c,v 1.6 1997/12/02 12:33:17 charnier Exp $";
#endif /* not lint */
/* debug print routines */
@ -63,7 +63,7 @@ print_request(cp, mp)
char tbuf[80], *tp;
if (mp->type > NTYPES) {
(void)sprintf(tbuf, "type %d", mp->type);
(void)snprintf(tbuf, sizeof(tbuf), "type %d", mp->type);
tp = tbuf;
} else
tp = types[mp->type];
@ -79,12 +79,12 @@ print_response(cp, rp)
char tbuf[80], *tp, abuf[80], *ap;
if (rp->type > NTYPES) {
(void)sprintf(tbuf, "type %d", rp->type);
(void)snprintf(tbuf, sizeof(tbuf), "type %d", rp->type);
tp = tbuf;
} else
tp = types[rp->type];
if (rp->answer > NANSWERS) {
(void)sprintf(abuf, "answer %d", rp->answer);
(void)snprintf(abuf, sizeof(abuf), "answer %d", rp->answer);
ap = abuf;
} else
ap = answers[rp->answer];