Check bounds before using index.
authorEmil Mikulic <emikulic@gmail.com>
Thu, 1 Sep 2016 07:49:06 +0000 (17:49 +1000)
committerEmil Mikulic <emikulic@gmail.com>
Thu, 1 Sep 2016 07:49:06 +0000 (17:49 +1000)
Reported by: David Binderman
Found with: cppcheck --enable=style

http.c

diff --git a/http.c b/http.c
index f32dce0..a03fdf7 100644 (file)
--- a/http.c
+++ b/http.c
@@ -469,8 +469,8 @@ static char *parse_field(const struct connection *conn, const char *field)
 
     /* find end */
     for (bound2 = bound1;
 
     /* find end */
     for (bound2 = bound1;
-        conn->request[bound2] != '\r' &&
-        bound2 < conn->request_length; bound2++)
+        bound2 < conn->request_length &&
+        conn->request[bound2] != '\r'; bound2++)
             ;
 
     /* copy to buffer */
             ;
 
     /* copy to buffer */