r66: fixed a segv when printing an error from a session setup failure. This
authorAndrew Tridgell <tridge@samba.org>
Tue, 6 Apr 2004 08:05:04 +0000 (08:05 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:50:41 +0000 (12:50 -0500)
was caused by the cli to cli->tree conversion a while ago
(This used to be commit f88f1d33618562f8b8273ec45a79b819c9e48686)

source4/client/client.c

index 61d52b82d96b6c094dfc53ce7cb3ab5fbca34279..0430689865c323e4341b879a278d8ea24b88d640 100644 (file)
@@ -2683,6 +2683,7 @@ static struct cli_state *do_connect(const char *server, const char *share)
        struct in_addr ip;
        fstring servicename;
        char *sharename;
+       NTSTATUS status;
        
        /* make a copy so we don't modify the global string 'service' */
        fstrcpy(servicename, share);
@@ -2745,12 +2746,14 @@ static struct cli_state *do_connect(const char *server, const char *share)
                }
        }
 
-       if (NT_STATUS_IS_ERR(cli_session_setup(c, username, password, 
-                                              lp_workgroup()))) {
+       status = cli_session_setup(c, username, password, lp_workgroup());
+       if (NT_STATUS_IS_ERR(status)) {
                /* if a password was not supplied then try again with a null username */
-               if (password[0] || !username[0] || use_kerberos ||
-                   NT_STATUS_IS_ERR(cli_session_setup(c, "", "", lp_workgroup()))) { 
-                       d_printf("session setup failed: %s\n", cli_errstr(c->tree));
+               if (password[0] || !username[0] || use_kerberos) {
+                       status = cli_session_setup(c, "", "", lp_workgroup());
+               }
+               if (NT_STATUS_IS_ERR(status)) {
+                       d_printf("session setup failed: %s\n", nt_errstr(status));
                        cli_shutdown(c);
                        return NULL;
                }