summaryrefslogtreecommitdiff
path: root/source3/rpcclient
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2012-12-21 15:52:02 +0100
committerGünther Deschner <gd@samba.org>2013-01-02 12:35:36 +0100
commit30e1dc08df8d891e1ab6e17d786a7a239417947f (patch)
tree266b20452a07d075f1803a5fe03f6a4558137b62 /source3/rpcclient
parentab14918ea406eed2ed79c39dea7b855e4ecbac74 (diff)
downloadsamba-30e1dc08df8d891e1ab6e17d786a7a239417947f.tar.gz
samba-30e1dc08df8d891e1ab6e17d786a7a239417947f.tar.bz2
samba-30e1dc08df8d891e1ab6e17d786a7a239417947f.zip
s3-rpcclient: Fix cmd_eventlog_readlog() null pointer passing.
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Günther Deschner <gd@samba.org> Found by Coverity.
Diffstat (limited to 'source3/rpcclient')
-rw-r--r--source3/rpcclient/cmd_eventlog.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/source3/rpcclient/cmd_eventlog.c b/source3/rpcclient/cmd_eventlog.c
index a9d971eb55..8acf4173b7 100644
--- a/source3/rpcclient/cmd_eventlog.c
+++ b/source3/rpcclient/cmd_eventlog.c
@@ -69,7 +69,7 @@ static NTSTATUS cmd_eventlog_readlog(struct rpc_pipe_client *cli,
EVENTLOG_SEQUENTIAL_READ;
uint32_t offset = 0;
uint32_t number_of_bytes = 0;
- uint8_t *data = NULL;
+ uint8_t *data;
uint32_t sent_size = 0;
uint32_t real_size = 0;
@@ -84,10 +84,6 @@ static NTSTATUS cmd_eventlog_readlog(struct rpc_pipe_client *cli,
if (argc >= 4) {
number_of_bytes = atoi(argv[3]);
- data = talloc_array(mem_ctx, uint8_t, number_of_bytes);
- if (!data) {
- goto done;
- }
}
status = get_eventlog_handle(cli, mem_ctx, argv[1], &handle);
@@ -95,6 +91,11 @@ static NTSTATUS cmd_eventlog_readlog(struct rpc_pipe_client *cli,
return status;
}
+ data = talloc_array(mem_ctx, uint8_t, number_of_bytes);
+ if (data == NULL) {
+ goto done;
+ }
+
do {
enum ndr_err_code ndr_err;
@@ -118,8 +119,8 @@ static NTSTATUS cmd_eventlog_readlog(struct rpc_pipe_client *cli,
if (NT_STATUS_EQUAL(result, NT_STATUS_BUFFER_TOO_SMALL) &&
real_size > 0 ) {
number_of_bytes = real_size;
- data = talloc_array(mem_ctx, uint8_t, real_size);
- if (!data) {
+ data = talloc_realloc(mem_ctx, data, uint8_t, real_size);
+ if (data == NULL) {
goto done;
}
status = dcerpc_eventlog_ReadEventLogW(b, mem_ctx,