diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-03-13 09:09:52 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-03-13 09:09:52 +0000 |
commit | cd64a50f546ecbfd25035373ee745bd04e4e5905 (patch) | |
tree | 86a1452cec538b8f5259a45745e95cd1161d04e7 /usr.bin/rpcgen | |
parent | 6153e3b8d9aedd43b1300c4d60217039c9485e02 (diff) |
lots of sprintf -> snprintf and strcpy -> strlcpy; checked by tedu
Diffstat (limited to 'usr.bin/rpcgen')
-rw-r--r-- | usr.bin/rpcgen/rpc_cout.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/usr.bin/rpcgen/rpc_cout.c b/usr.bin/rpcgen/rpc_cout.c index 6430b78249f..be22d6a5982 100644 --- a/usr.bin/rpcgen/rpc_cout.c +++ b/usr.bin/rpcgen/rpc_cout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rpc_cout.c,v 1.13 2002/07/05 05:39:42 deraadt Exp $ */ +/* $OpenBSD: rpc_cout.c,v 1.14 2003/03/13 09:09:34 deraadt Exp $ */ /* $NetBSD: rpc_cout.c,v 1.6 1996/10/01 04:13:53 cgd Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -354,17 +354,19 @@ emit_union(def) continue; cs = &cl->case_decl; if (!streq(cs->type, "void")) { - object = alloc(strlen(def->def_name) + strlen(format) + - strlen(cs->name) + 1); + int len = strlen(def->def_name) + strlen(format) + + strlen(cs->name) + 1; + + object = alloc(len); if (object == NULL) { fprintf(stderr, "Fatal error : no memory\n"); crash(); } if (isvectordef(cs->type, cs->rel)) { - sprintf(object, vecformat, def->def_name, + snprintf(object, len, vecformat, def->def_name, cs->name); } else { - sprintf(object, format, def->def_name, + snprintf(object, len, format, def->def_name, cs->name); } print_ifstat(2, cs->prefix, cs->type, cs->rel, cs->array_max, @@ -376,18 +378,20 @@ emit_union(def) dflt = def->def.un.default_decl; if (dflt != NULL) { if (!streq(dflt->type, "void")) { + int len = strlen(def->def_name) + strlen(format) + + strlen(dflt->name) + 1; + fprintf(fout, "\tdefault:\n"); - object = alloc(strlen(def->def_name) + strlen(format) + - strlen(dflt->name) + 1); + object = alloc(len); if (object == NULL) { fprintf(stderr, "Fatal error : no memory\n"); crash(); } if (isvectordef(dflt->type, dflt->rel)) { - sprintf(object, vecformat, def->def_name, + snprintf(object, len, vecformat, def->def_name, dflt->name); } else { - sprintf(object, format, def->def_name, + snprintf(object, len, format, def->def_name, dflt->name); } |