r16945: Sync trunk -> 3.0 for 3.0.24 code. Still need
[tprouty/samba.git] / source / client / smbctool.c
index 5b21d195b76521d7f7f4b6d6ae2bc72fc46a2bc1..b7042f99cb2a5a8dc6389addeb133548a06397fc 100644 (file)
@@ -528,7 +528,14 @@ static void adjust_do_list_queue(void)
         * If the starting point of the queue is more than half way through,
         * move everything toward the beginning.
         */
-       if (do_list_queue && (do_list_queue_start == do_list_queue_end)) {
+
+       if (do_list_queue == NULL) {
+               DEBUG(4,("do_list_queue is empty\n"));
+               do_list_queue_start = do_list_queue_end = 0;
+               return;
+       }
+               
+       if (do_list_queue_start == do_list_queue_end) {
                DEBUG(4,("do_list_queue is empty\n"));
                do_list_queue_start = do_list_queue_end = 0;
                *do_list_queue = '\0';
@@ -3487,7 +3494,7 @@ static int do_message_op(void)
 
        msg_port = port ? port : 139;
 
-       if (!(cli=cli_initialise(NULL)) || (cli_set_port(cli, msg_port) != msg_port) ||
+       if (!(cli=cli_initialise()) || (cli_set_port(cli, msg_port) != msg_port) ||
                !cli_connect(cli, server_name, &ip)) {
                d_printf("Connection to %s failed\n", desthost);
                return 1;
@@ -3561,10 +3568,11 @@ static int do_message_op(void)
        set_global_myname( "" );
 
                /* set default debug level to 0 regardless of what smb.conf sets */
-       setup_logging( "smbclient", True );
+       setup_logging( "smbctool", True );
        DEBUGLEVEL_CLASS[DBGC_ALL] = 1;
-       dbf = x_stderr;
-       x_setbuf( x_stderr, NULL );
+       if ((dbf = x_fdup(x_stderr))) {
+               x_setbuf( dbf, NULL );
+       }
 
        pc = poptGetContext("smbclient", argc, (const char **) argv, long_options, 
                                POPT_CONTEXT_KEEP_FIRST);
@@ -3597,6 +3605,9 @@ static int do_message_op(void)
                        }
                        break;
                case 'E':
+                       if (dbf) {
+                               x_fclose(dbf);
+                       }
                        dbf = x_stderr;
                        display_set_stderr();
                        break;