r9389: handle errors reading from files in web server
authorAndrew Tridgell <tridge@samba.org>
Thu, 18 Aug 2005 12:19:16 +0000 (12:19 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:33:32 +0000 (13:33 -0500)
bug found by coverity
(This used to be commit 1a3229777adf12f8148267af7b33689ebe880ed8)

source4/web_server/web_server.c

index 80e479d8a7edcacd1da1c5cc3b531048a3705a9f..4962185526707c4fdf838a0484e2de8e3e291e78 100644 (file)
@@ -153,13 +153,14 @@ static void websrv_send(struct stream_connection *conn, uint16_t flags)
                web->output.nsent = 0;
 
                nread = read(web->output.fd, buf, sizeof(buf));
-               if (nread == 0) {
-                       close(web->output.fd);
-                       web->output.fd = -1;
-               }
                if (nread == -1 && errno == EINTR) {
                        return;
                }
+               if (nread <= 0) {
+                       close(web->output.fd);
+                       web->output.fd = -1;
+                       nread = 0;
+               }
                web->output.content = data_blob_talloc(web, buf, nread);
        }