Check bounds before using index.
[darkstat] / 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;
-        conn->request[bound2] != '\r' &&
-        bound2 < conn->request_length; bound2++)
+        bound2 < conn->request_length &&
+        conn->request[bound2] != '\r'; bound2++)
             ;
 
     /* copy to buffer */