From 30e1dc08df8d891e1ab6e17d786a7a239417947f Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Fri, 21 Dec 2012 15:52:02 +0100 Subject: s3-rpcclient: Fix cmd_eventlog_readlog() null pointer passing. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andreas Schneider Reviewed-by: Günther Deschner Found by Coverity. --- source3/rpcclient/cmd_eventlog.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'source3/rpcclient') 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, -- cgit