]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: http: fix a build warning introduced by a recent fix
authorWilly Tarreau <w@1wt.eu>
Sun, 13 Mar 2016 07:17:02 +0000 (08:17 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 13 Mar 2016 07:17:02 +0000 (08:17 +0100)
Cyril reported that recent commit 320ec2a ("BUG/MEDIUM: chunks: always
reject negative-length chunks") introduced a build warning because gcc
cannot guess that we can't fall into the case where the auth_method
chunk is not initialized.

This patch addresses it, though for the long term it would be best
if chunk_initlen() would always initialize the result.

This fix must be backported to 1.6 and 1.5 where the aforementionned
fix was already backported.

src/proto_http.c

index 8b5caad85802c6b41aeac3723d5bba23fc5df788..b7654a67a565d8aee919822ca99915666d458f1d 100644 (file)
@@ -1585,11 +1585,12 @@ get_http_auth(struct stream *s)
        h = ctx.line + ctx.val;
 
        p = memchr(h, ' ', ctx.vlen);
-       if (!p || p == h)
+       len = p - h;
+       if (!p || len <= 0)
                return 0;
 
-       chunk_initlen(&auth_method, h, 0, p-h);
-       chunk_initlen(&txn->auth.method_data, p+1, 0, ctx.vlen-(p-h)-1);
+       chunk_initlen(&auth_method, h, 0, len);
+       chunk_initlen(&txn->auth.method_data, p + 1, 0, ctx.vlen - len - 1);
 
        if (!strncasecmp("Basic", auth_method.str, auth_method.len)) {