r14087: Protect against domain being NULL. Finish Coverity #152.
authorJeremy Allison <jra@samba.org>
Thu, 9 Mar 2006 18:35:57 +0000 (18:35 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 16:11:11 +0000 (11:11 -0500)
Jeremy.
(This used to be commit 88dd4ab48127bb08fdeb0b5c236020e0b910f0d8)

source3/utils/net_rpc_join.c

index ddd1623d8b729597eb5242f1de309f4eb6733c7e..d611940e656b3c459ae2bc204263fbcf1eec320f 100644 (file)
@@ -196,6 +196,12 @@ int net_rpc_join_newstyle(int argc, const char **argv)
        rpccli_lsa_close(pipe_hnd, mem_ctx, &lsa_pol);
        cli_rpc_pipe_close(pipe_hnd); /* Done with this pipe */
 
+       /* Bail out if domain didn't get set. */
+       if (!domain) {
+               DEBUG(0, ("Could not get domain name.\n"));
+               goto done;
+       }
+
        /* Create domain user */
        pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SAMR, &result);
        if (!pipe_hnd) {
@@ -402,10 +408,12 @@ done:
 
        /* Display success or failure */
 
-       if (retval != 0) {
-               fprintf(stderr,"Unable to join domain %s.\n",domain);
-       } else {
-               printf("Joined domain %s.\n",domain);
+       if (domain) {
+               if (retval != 0) {
+                       fprintf(stderr,"Unable to join domain %s.\n",domain);
+               } else {
+                       printf("Joined domain %s.\n",domain);
+               }
        }
        
        cli_shutdown(cli);