Fix a potential hang on an empty file list.
authorWayne Davison <wayned@samba.org>
Sun, 11 Sep 2011 18:07:02 +0000 (11:07 -0700)
committerWayne Davison <wayned@samba.org>
Sun, 11 Sep 2011 18:08:14 +0000 (11:08 -0700)
Fixes bug 8423.

io.c
main.c

diff --git a/io.c b/io.c
index 7cb3be137c8c8862c9694075df13940004dd19a8..b4e0a682a74c14e62bd639ff3978d764643a2314 100644 (file)
--- a/io.c
+++ b/io.c
@@ -912,6 +912,9 @@ void noop_io_until_death(void)
 {
        char buf[1024];
 
+       if (!iobuf.in.buf || !iobuf.out.buf || iobuf.in_fd == -1 || iobuf.out_fd == -1)
+               return;
+
        kluge_around_eof = 2;
        /* Setting an I/O timeout ensures that if something inexplicably weird
         * happens, we won't hang around forever. */
diff --git a/main.c b/main.c
index 5a06f177ca6e474fe84b88b167d52b47796bb09a..c5e106c948659042fcf6d85b9afee6db35bd4ba9 100644 (file)
--- a/main.c
+++ b/main.c
@@ -809,8 +809,12 @@ static void do_server_sender(int f_in, int f_out, int argc, char *argv[])
        }
 
        flist = send_file_list(f_out,argc,argv);
-       if (!flist || flist->used == 0)
+       if (!flist || flist->used == 0) {
+               /* Make sure input buffering is off so we can't hang in noop_io_until_death(). */
+               io_end_buffering_in(0);
+               /* TODO:  we should really exit in a more controlled manner. */
                exit_cleanup(0);
+       }
 
        io_start_buffering_in(f_in);