From 95a81a33513517c25476286453c89ab1884e9919 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 28 Jun 2006 04:27:43 +0000 Subject: r16606: Klocwork #1990. Malloc the correct size. Jeremy. (This used to be commit d1a1c4e092877a6ea0f98eed2a37a96d42c36323) --- source3/libsmb/clirap2.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/libsmb/clirap2.c b/source3/libsmb/clirap2.c index a327bae317..147683689d 100644 --- a/source3/libsmb/clirap2.c +++ b/source3/libsmb/clirap2.c @@ -211,11 +211,20 @@ int cli_NetGroupAdd(struct cli_state *cli, RAP_GROUP_INFO_1 * grinfo ) +WORDSIZE /* info level */ +WORDSIZE]; /* reserved word */ - char data[1024]; - /* offset into data of free format strings. Will be updated */ /* by PUTSTRINGP macro and end up with total data length. */ int soffset = RAP_GROUPNAME_LEN + 1 + DWORDSIZE; + char *data; + size_t data_size; + + /* Allocate data. */ + data_size = MAX(soffset + strlen(grinfo->comment) + 1, 1024); + + data = SMB_MALLOC(data_size); + if (!data) { + DEBUG (1, ("Malloc fail\n")); + return -1; + } /* now send a SMBtrans command with api WGroupAdd */ @@ -253,6 +262,7 @@ int cli_NetGroupAdd(struct cli_state *cli, RAP_GROUP_INFO_1 * grinfo ) DEBUG(4,("NetGroupAdd failed\n")); } + SAFE_FREE(data); SAFE_FREE(rparam); SAFE_FREE(rdata); -- cgit