summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2007-05-30 21:46:03 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:22:59 -0500
commit05c68d98c10c9aa62d75bdcafee7f5abb079728d (patch)
tree13ffca07af43f54431f356449aa661448a11cc25 /source3
parente6e577b845db9530aa95d696d9f4f7d31a2b4140 (diff)
downloadsamba-05c68d98c10c9aa62d75bdcafee7f5abb079728d.tar.gz
samba-05c68d98c10c9aa62d75bdcafee7f5abb079728d.tar.bz2
samba-05c68d98c10c9aa62d75bdcafee7f5abb079728d.zip
r23249: another sync from 3.0.26 for the echo work to rpcclient
(This used to be commit 7aa1f89eb369805e3c3e36b4d62dddbea9dfab2f)
Diffstat (limited to 'source3')
-rw-r--r--source3/rpcclient/cmd_echo.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/source3/rpcclient/cmd_echo.c b/source3/rpcclient/cmd_echo.c
index 81028dfb73..d9d14247f4 100644
--- a/source3/rpcclient/cmd_echo.c
+++ b/source3/rpcclient/cmd_echo.c
@@ -52,7 +52,7 @@ static NTSTATUS cmd_echo_data(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
{
uint32 size, i;
NTSTATUS result;
- uint8 *in_data = NULL, *out_data = NULL;
+ uint8_t *in_data = NULL, *out_data = NULL;
if (argc != 2) {
printf("Usage: %s num\n", argv[0]);
@@ -60,8 +60,16 @@ static NTSTATUS cmd_echo_data(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
}
size = atoi(argv[1]);
- in_data = (uint8 *)SMB_MALLOC(size);
- out_data = (uint8 *)SMB_MALLOC(size);
+ if ( (in_data = (uint8_t*)SMB_MALLOC(size)) == NULL ) {
+ printf("Failure to allocate buff of %d bytes\n",
+ size);
+ goto done;
+ }
+ if ( (out_data = (uint8_t*)SMB_MALLOC(size)) == NULL ) {
+ printf("Failure to allocate buff of %d bytes\n",
+ size);
+ goto done;
+ }
for (i = 0; i < size; i++)
in_data[i] = i & 0xff;
@@ -81,7 +89,7 @@ static NTSTATUS cmd_echo_data(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
done:
SAFE_FREE(in_data);
- TALLOC_FREE(out_data);
+ SAFE_FREE(out_data);
return result;
}
@@ -92,7 +100,7 @@ static NTSTATUS cmd_echo_source_data(struct rpc_pipe_client *cli,
{
uint32 size, i;
NTSTATUS result;
- uint8 *out_data;
+ uint8_t *out_data = NULL;
if (argc != 2) {
printf("Usage: %s num\n", argv[0]);
@@ -100,15 +108,20 @@ static NTSTATUS cmd_echo_source_data(struct rpc_pipe_client *cli,
}
size = atoi(argv[1]);
+ if ( (out_data = (uint8_t*)SMB_MALLOC(size)) == NULL ) {
+ printf("Failure to allocate buff of %d bytes\n",
+ size);
+ goto done;
+ }
+
- out_data = SMB_MALLOC_ARRAY(uint8, size);
result = rpccli_echo_SourceData(cli, mem_ctx, size, out_data);
if (!NT_STATUS_IS_OK(result))
goto done;
for (i = 0; i < size; i++) {
- if (out_data[i] != (i & 0xff)) {
+ if (out_data && out_data[i] != (i & 0xff)) {
printf("mismatch at offset %d, %d != %d\n",
i, out_data[i], i & 0xff);
result = NT_STATUS_UNSUCCESSFUL;
@@ -116,8 +129,6 @@ static NTSTATUS cmd_echo_source_data(struct rpc_pipe_client *cli,
}
done:
- TALLOC_FREE(out_data);
-
return result;
}
@@ -126,7 +137,7 @@ static NTSTATUS cmd_echo_sink_data(struct rpc_pipe_client *cli, TALLOC_CTX *mem_
{
uint32 size, i;
NTSTATUS result;
- uint8 *in_data = NULL;
+ uint8_t *in_data = NULL;
if (argc != 2) {
printf("Usage: %s num\n", argv[0]);
@@ -134,7 +145,11 @@ static NTSTATUS cmd_echo_sink_data(struct rpc_pipe_client *cli, TALLOC_CTX *mem_
}
size = atoi(argv[1]);
- in_data = (uint8 *)SMB_MALLOC(size);
+ if ( (in_data = (uint8_t*)SMB_MALLOC(size)) == NULL ) {
+ printf("Failure to allocate buff of %d bytes\n",
+ size);
+ goto done;
+ }
for (i = 0; i < size; i++)
in_data[i] = i & 0xff;