mirror of
https://github.com/samba-team/samba.git
synced 2025-07-15 16:59:09 +03:00
r16606: Klocwork #1990. Malloc the correct size.
Jeremy.
(This used to be commit d1a1c4e092
)
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
5fb4cc9dff
commit
95a81a3351
@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user