From 4558acfaa92f3b47dafa7cd3649c3acc4338f4a1 Mon Sep 17 00:00:00 2001 From: millert Date: Sun, 15 Sep 1996 22:58:08 +0000 Subject: [PATCH] sprintf -> snprintf paranoia --- bin/sh/mkinit.c | 6 +++--- bin/sh/mknodes.c | 12 ++++++------ bin/sh/mksyntax.c | 9 +++++---- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/bin/sh/mkinit.c b/bin/sh/mkinit.c index 8a5df1ff9d0..9750b99813c 100644 --- a/bin/sh/mkinit.c +++ b/bin/sh/mkinit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkinit.c,v 1.3 1996/06/23 14:21:23 deraadt Exp $ */ +/* $OpenBSD: mkinit.c,v 1.4 1996/09/15 22:58:09 millert Exp $ */ /* $NetBSD: mkinit.c,v 1.14 1996/02/18 12:29:21 mycroft Exp $ */ /*- @@ -47,7 +47,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)mkinit.c 8.2 (Berkeley) 5/4/95"; #else -static char rcsid[] = "$OpenBSD: mkinit.c,v 1.3 1996/06/23 14:21:23 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: mkinit.c,v 1.4 1996/09/15 22:58:09 millert Exp $"; #endif #endif /* not lint */ @@ -275,7 +275,7 @@ doevent(ep, fp, fname) int indent; char *p; - sprintf(line, "\n /* from %s: */\n", fname); + snprintf(line, sizeof(line), "\n /* from %s: */\n", fname); addstr(line, &ep->code); addstr(" {\n", &ep->code); for (;;) { diff --git a/bin/sh/mknodes.c b/bin/sh/mknodes.c index ddf3dc2b2e3..ef4cc33c706 100644 --- a/bin/sh/mknodes.c +++ b/bin/sh/mknodes.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mknodes.c,v 1.2 1996/06/23 14:21:24 deraadt Exp $ */ +/* $OpenBSD: mknodes.c,v 1.3 1996/09/15 22:58:09 millert Exp $ */ /* $NetBSD: mknodes.c,v 1.11 1995/05/11 21:29:36 christos Exp $ */ /*- @@ -47,7 +47,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)mknodes.c 8.2 (Berkeley) 5/4/95"; #else -static char rcsid[] = "$OpenBSD: mknodes.c,v 1.2 1996/06/23 14:21:24 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: mknodes.c,v 1.3 1996/09/15 22:58:09 millert Exp $"; #endif #endif /* not lint */ @@ -187,16 +187,16 @@ parsefield() fp->name = savestr(name); if (strcmp(type, "nodeptr") == 0) { fp->type = T_NODE; - sprintf(decl, "union node *%s", name); + snprintf(decl, sizeof(decl), "union node *%s", name); } else if (strcmp(type, "nodelist") == 0) { fp->type = T_NODELIST; - sprintf(decl, "struct nodelist *%s", name); + snprintf(decl, sizeof(decl), "struct nodelist *%s", name); } else if (strcmp(type, "string") == 0) { fp->type = T_STRING; - sprintf(decl, "char *%s", name); + snprintf(decl, sizeof(decl), "char *%s", name); } else if (strcmp(type, "int") == 0) { fp->type = T_INT; - sprintf(decl, "int %s", name); + snprintf(decl, sizeof(decl), "int %s", name); } else if (strcmp(type, "other") == 0) { fp->type = T_OTHER; } else if (strcmp(type, "temp") == 0) { diff --git a/bin/sh/mksyntax.c b/bin/sh/mksyntax.c index 947e7090a99..5506ba70623 100644 --- a/bin/sh/mksyntax.c +++ b/bin/sh/mksyntax.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mksyntax.c,v 1.2 1996/06/23 14:21:24 deraadt Exp $ */ +/* $OpenBSD: mksyntax.c,v 1.3 1996/09/15 22:58:08 millert Exp $ */ /* $NetBSD: mksyntax.c,v 1.11 1995/05/11 21:29:37 christos Exp $ */ /*- @@ -47,7 +47,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)mksyntax.c 8.2 (Berkeley) 5/4/95"; #else -static char rcsid[] = "$OpenBSD: mksyntax.c,v 1.2 1996/06/23 14:21:24 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: mksyntax.c,v 1.3 1996/09/15 22:58:08 millert Exp $"; #endif #endif /* not lint */ @@ -176,7 +176,7 @@ main(argc, argv) /* Generate the #define statements in the header file */ fputs("/* Syntax classes */\n", hfile); for (i = 0 ; synclass[i].name ; i++) { - sprintf(buf, "#define %s %d", synclass[i].name, i); + snprintf(buf, sizeof(buf), "#define %s %d", synclass[i].name, i); fputs(buf, hfile); for (pos = strlen(buf) ; pos < 32 ; pos = (pos + 8) & ~07) putc('\t', hfile); @@ -185,7 +185,8 @@ main(argc, argv) putc('\n', hfile); fputs("/* Syntax classes for is_ functions */\n", hfile); for (i = 0 ; is_entry[i].name ; i++) { - sprintf(buf, "#define %s %#o", is_entry[i].name, 1 << i); + snprintf(buf, sizeof(buf), "#define %s %#o", + is_entry[i].name, 1 << i); fputs(buf, hfile); for (pos = strlen(buf) ; pos < 32 ; pos = (pos + 8) & ~07) putc('\t', hfile); -- 2.20.1