]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
rpc_client: Don't pass a NULL string to talloc_asprintf
authorVolker Lendecke <vl@samba.org>
Tue, 24 Sep 2019 17:29:07 +0000 (10:29 -0700)
committerRalph Boehme <slow@samba.org>
Wed, 2 Oct 2019 08:01:40 +0000 (08:01 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/rpc_client/cli_pipe.c

index 78197d99f9ce844fb962b5517cd4f27e0edcdfee..1276eaf9807246650a6f55203ff97f6972fa56c3 100644 (file)
@@ -2665,9 +2665,14 @@ static NTSTATUS rpc_pipe_open_tcp_port(TALLOC_CTX *mem_ctx, const char *host,
        result->transfer_syntax = ndr_transfer_syntax_ndr;
 
        result->desthost = talloc_strdup(result, host);
+       if (result->desthost == NULL) {
+               status = NT_STATUS_NO_MEMORY;
+               goto fail;
+       }
+
        result->srv_name_slash = talloc_asprintf_strupper_m(
                result, "\\\\%s", result->desthost);
-       if ((result->desthost == NULL) || (result->srv_name_slash == NULL)) {
+       if (result->srv_name_slash == NULL) {
                status = NT_STATUS_NO_MEMORY;
                goto fail;
        }
@@ -2912,9 +2917,14 @@ NTSTATUS rpc_pipe_open_ncalrpc(TALLOC_CTX *mem_ctx, const char *socket_path,
        result->transfer_syntax = ndr_transfer_syntax_ndr;
 
        result->desthost = get_myname(result);
+       if (result->desthost == NULL) {
+               status = NT_STATUS_NO_MEMORY;
+               goto fail;
+       }
+
        result->srv_name_slash = talloc_asprintf_strupper_m(
                result, "\\\\%s", result->desthost);
-       if ((result->desthost == NULL) || (result->srv_name_slash == NULL)) {
+       if (result->srv_name_slash == NULL) {
                status = NT_STATUS_NO_MEMORY;
                goto fail;
        }
@@ -3006,17 +3016,23 @@ static NTSTATUS rpc_pipe_open_np(struct cli_state *cli,
 
        result->abstract_syntax = table->syntax_id;
        result->transfer_syntax = ndr_transfer_syntax_ndr;
-       result->desthost = talloc_strdup(result, smbXcli_conn_remote_name(cli->conn));
-       result->srv_name_slash = talloc_asprintf_strupper_m(
-               result, "\\\\%s", result->desthost);
 
-       result->max_xmit_frag = RPC_MAX_PDU_FRAG_LEN;
+       result->desthost = talloc_strdup(
+               result, smbXcli_conn_remote_name(cli->conn));
+       if (result->desthost == NULL) {
+               TALLOC_FREE(result);
+               return NT_STATUS_NO_MEMORY;
+       }
 
-       if ((result->desthost == NULL) || (result->srv_name_slash == NULL)) {
+       result->srv_name_slash = talloc_asprintf_strupper_m(
+               result, "\\\\%s", result->desthost);
+       if (result->srv_name_slash == NULL) {
                TALLOC_FREE(result);
                return NT_STATUS_NO_MEMORY;
        }
 
+       result->max_xmit_frag = RPC_MAX_PDU_FRAG_LEN;
+
        status = rpc_transport_np_init(result, cli, table,
                                       &result->transport);
        if (!NT_STATUS_IS_OK(status)) {