diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2002-07-14 02:59:42 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2002-07-14 02:59:42 +0000 |
commit | c0f7498575f310c0d1bbc1e1042e7c60c8ddced0 (patch) | |
tree | d558ac13ab46aa7bc11f981b5f08c51ea2c63858 /usr.sbin/config/mkheaders.c | |
parent | 6715eae37fa352fa839662463dd316eae343b4de (diff) |
kill sprintf
Diffstat (limited to 'usr.sbin/config/mkheaders.c')
-rw-r--r-- | usr.sbin/config/mkheaders.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/usr.sbin/config/mkheaders.c b/usr.sbin/config/mkheaders.c index 8d067d0f999..7bc78f6601a 100644 --- a/usr.sbin/config/mkheaders.c +++ b/usr.sbin/config/mkheaders.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkheaders.c,v 1.13 2002/05/29 09:45:39 deraadt Exp $ */ +/* $OpenBSD: mkheaders.c,v 1.14 2002/07/14 02:59:41 deraadt Exp $ */ /* $NetBSD: mkheaders.c,v 1.12 1997/02/02 21:12:34 thorpej Exp $ */ /* @@ -132,22 +132,31 @@ emitopt(nv) { struct nvlist *option; char new_contents[BUFSIZ], buf[BUFSIZ]; - char fname[BUFSIZ], *p; + char fname[BUFSIZ], totlen; int nlines; FILE *fp; /* * Generate the new contents of the file. */ - p = new_contents; if ((option = ht_lookup(opttab, nv->nv_str)) == NULL) - p += sprintf(p, "/* option `%s' not defined */\n", + totlen = snprintf(new_contents, sizeof new_contents, + "/* option `%s' not defined */\n", nv->nv_str); else { - p += sprintf(p, "#define\t%s", option->nv_name); if (option->nv_str != NULL) - p += sprintf(p, "\t%s", option->nv_str); - p += sprintf(p, "\n"); + totlen = snprintf(new_contents, sizeof new_contents, + "#define\t%s\t%s\n", + option->nv_name, option->nv_str); + else + totlen = snprintf(new_contents, sizeof new_contents, + "#define\t%s\n", + option->nv_name); + } + + if (totlen >= sizeof new_contents) { + fprintf(stderr, "config: string too long\n"); + return (1); } /* |