diff options
author | Peter Valchev <pvalchev@cvs.openbsd.org> | 2003-04-26 18:29:52 +0000 |
---|---|---|
committer | Peter Valchev <pvalchev@cvs.openbsd.org> | 2003-04-26 18:29:52 +0000 |
commit | cae6653389d443e6cadd288b2eb60ad91a6c43c4 (patch) | |
tree | eef85fff055e555d7100bf4346378880a86b5ea2 /usr.bin | |
parent | 8c652134c617bfff0d20bec0aed52aa35d3caf61 (diff) |
get rid of incorrectly sized buffer by using strdup/asprintf,
also simplifies things; ok millert
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/rpcgen/rpc_parse.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/usr.bin/rpcgen/rpc_parse.c b/usr.bin/rpcgen/rpc_parse.c index 4ba914b1ce6..e815939739e 100644 --- a/usr.bin/rpcgen/rpc_parse.c +++ b/usr.bin/rpcgen/rpc_parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rpc_parse.c,v 1.11 2002/07/05 05:39:42 deraadt Exp $ */ +/* $OpenBSD: rpc_parse.c,v 1.12 2003/04/26 18:29:51 pvalchev Exp $ */ /* $NetBSD: rpc_parse.c,v 1.5 1995/08/29 23:05:55 cgd Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -478,7 +478,6 @@ get_prog_declaration(dec, dkind, num) int num; /* arg number */ { token tok; - char name[10]; /* argument name */ if (dkind == DEF_PROGRAM) { peek(&tok); @@ -492,17 +491,16 @@ get_prog_declaration(dec, dkind, num) } get_type(&dec->prefix, &dec->type, dkind); dec->rel = REL_ALIAS; - if (peekscan(TOK_IDENT, &tok)) /* optional name of argument */ - strlcpy(name, tok.str, sizeof name); - else { + if (peekscan(TOK_IDENT, &tok)) { /* optional name of argument */ + dec->name = (char *)strdup(tok.str); + if (dec->name == NULL) + error("out of memory"); + } else { /* default name of argument */ - snprintf(name, sizeof name, "%s%d", ARGNAME, num); + if (asprintf(&dec->name, "%s%d", ARGNAME, num) == -1) + error("out of memory"); } - dec->name = (char *)strdup(name); - if (dec->name == NULL) - error("out of memory"); - if (streq(dec->type, "void")) return; |