summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-06-28 04:27:43 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:19:03 -0500
commit95a81a33513517c25476286453c89ab1884e9919 (patch)
treea155efdec5108edc4ee227cfd72c9e76764078c2 /source3
parent5fb4cc9dff3c27c98ec4390d1a1836a3ea9373c2 (diff)
downloadsamba-95a81a33513517c25476286453c89ab1884e9919.tar.gz
samba-95a81a33513517c25476286453c89ab1884e9919.tar.bz2
samba-95a81a33513517c25476286453c89ab1884e9919.zip
r16606: Klocwork #1990. Malloc the correct size.
Jeremy. (This used to be commit d1a1c4e092877a6ea0f98eed2a37a96d42c36323)
Diffstat (limited to 'source3')
-rw-r--r--source3/libsmb/clirap2.c14
1 files changed, 12 insertions, 2 deletions
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);