Check the bound first.
authorEmil Mikulic <emikulic@gmail.com>
Tue, 19 May 2015 14:06:59 +0000 (00:06 +1000)
committerEmil Mikulic <emikulic@gmail.com>
Tue, 19 May 2015 14:06:59 +0000 (00:06 +1000)
Found with cppcheck.

darkhttpd.c

index eb47c54..b8d4180 100644 (file)
@@ -1461,9 +1461,9 @@ static char *parse_field(const struct connection *conn, const char *field) {
 
     /* find end */
     for (bound2 = bound1;
-         ((conn->request[bound2] != '\r') &&
-          (conn->request[bound2] != '\n') &&
-          (bound2 < conn->request_length));
+         ((bound2 < conn->request_length) &&
+          (conn->request[bound2] != '\r') &&
+          (conn->request[bound2] != '\n'));
          bound2++)
             ;