s3-rpc_client: Do not give NT_STATUS_NO_MEMORY when the source string was NULL
authorAndrew Bartlett <abartlet@samba.org>
Mon, 18 Aug 2014 02:13:39 +0000 (14:13 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Sun, 31 Aug 2014 22:36:42 +0000 (00:36 +0200)
Change-Id: I25a4dcc2239267ee7c219e965693027ca2981983
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-By: Jelmer Vernooij <jelmer@samba.org>
source3/rpc_client/cli_pipe.c

index 07fa5598d1997d9be4fa8afc62c446f9211b093d..ce247ff537e049f9b292c2ebec1ce34984af03bb 100644 (file)
@@ -2873,6 +2873,12 @@ NTSTATUS cli_rpc_pipe_open_noauth_transport(struct cli_state *cli,
        auth->user_name = talloc_strdup(auth, cli->user_name);
        auth->domain = talloc_strdup(auth, cli->domain);
 
+       if ((cli->user_name != NULL && auth->user_name == NULL)
+           || (cli->domain != NULL && auth->domain == NULL)) {
+               TALLOC_FREE(result);
+               return NT_STATUS_NO_MEMORY;
+       }
+
        if (transport == NCACN_NP) {
                struct smbXcli_session *session;
 
@@ -2889,11 +2895,6 @@ NTSTATUS cli_rpc_pipe_open_noauth_transport(struct cli_state *cli,
                }
        }
 
-       if ((auth->user_name == NULL) || (auth->domain == NULL)) {
-               TALLOC_FREE(result);
-               return NT_STATUS_NO_MEMORY;
-       }
-
        status = rpc_pipe_bind(result, auth);
        if (!NT_STATUS_IS_OK(status)) {
                int lvl = 0;