]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] frontend: improve accept-proxy header parsing
authorEmeric Brun <ebrun@exceliance.fr>
Fri, 29 Oct 2010 13:16:55 +0000 (15:16 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 30 Oct 2010 17:04:38 +0000 (19:04 +0200)
The accept-proxy now automatically fails as soon as a character does not
match the expected syntax.

src/frontend.c

index 9e7be10cc5ccf2553aa5790c9e9a0a4d1dbee1c8..348e999a0ea923ccf6e7c5acf4c5bbbda4708bf5 100644 (file)
@@ -287,13 +287,17 @@ int frontend_decode_proxy_request(struct session *s, struct buffer *req, int an_
        if (req->flags & (BF_READ_ERROR|BF_READ_TIMEOUT))
                goto fail;
 
-       if (req->l < 18) /* shortest possible line */
+       len = MIN(req->l, 6);
+       if (!len)
                goto missing;
 
-       /* Decode a possible proxy request */
-       if (memcmp(line, "PROXY ", 6) != 0)
+       /* Decode a possible proxy request, fail early if it does not match */
+       if (strncmp(line, "PROXY ", len) != 0)
                goto fail;
+
        line += 6;
+       if (req->l < 18) /* shortest possible line */
+               goto missing;
 
        if (memcmp(line, "TCP4 ", 5) != 0)
                goto fail;