reply_sent is zero in poll_send_header_and_reply
authorEmil Mikulic <emikulic@gmail.com>
Sun, 15 May 2011 14:00:59 +0000 (00:00 +1000)
committerEmil Mikulic <emikulic@gmail.com>
Sat, 4 Jun 2011 14:00:30 +0000 (00:00 +1000)
Found by: Clang Static Analyzer

http.c

diff --git a/http.c b/http.c
index e3b02b1..418e481 100644 (file)
--- a/http.c
+++ b/http.c
@@ -772,8 +772,8 @@ static void poll_send_header_and_reply(struct connection *conn)
     iov[0].iov_base = conn->header;
     iov[0].iov_len = conn->header_length;
 
-    iov[1].iov_base = conn->reply + conn->reply_sent;
-    iov[1].iov_len = conn->reply_length - conn->reply_sent;
+    iov[1].iov_base = conn->reply;
+    iov[1].iov_len = conn->reply_length;
 
     sent = writev(conn->socket, iov, 2);
     conn->last_active = now;
@@ -798,7 +798,7 @@ static void poll_send_header_and_reply(struct connection *conn)
     conn->header_sent = conn->header_length;
     sent -= conn->header_length;
 
-    if (conn->reply_sent + sent < conn->reply_length) {
+    if (sent < (ssize_t)conn->reply_length) {
         verbosef("partially sent reply");
         conn->reply_sent += sent;
         conn->state = SEND_REPLY;