]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] fix wrong pointer arithmetics in HTTP message captures
authorWilly Tarreau <w@1wt.eu>
Fri, 1 May 2009 09:33:17 +0000 (11:33 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 1 May 2009 09:33:17 +0000 (11:33 +0200)
The pointer arithmetics was wrong in http_capture_bad_message().
This has no impact right now because the error only msg->som was
affected and right now it's always 0. But this was a bug waiting
for keepalive support to strike.

src/proto_http.c

index 3dd11ec73860939b180f86311de9548bbb33bc5d..de93ccc3eb93e7721b220a96fbc62c13aec701e2 100644 (file)
@@ -4392,14 +4392,12 @@ void http_capture_bad_message(struct error_snapshot *es, struct session *s,
                               struct buffer *buf, struct http_msg *msg,
                              struct proxy *other_end)
 {
-       int maxlen = MIN(buf->r - buf->data + msg->som, sizeof(es->buf));
-
-       memcpy(es->buf, buf->data + msg->som, maxlen);
+       es->len = buf->r - (buf->data + msg->som);
+       memcpy(es->buf, buf->data + msg->som, MIN(es->len, sizeof(es->buf)));
        if (msg->err_pos >= 0)
-               es->pos  = msg->err_pos + msg->som;
+               es->pos  = msg->err_pos - msg->som;
        else
-               es->pos  = buf->lr - buf->data + msg->som;
-       es->len  = buf->r - buf->data + msg->som;
+               es->pos  = buf->lr - (buf->data + msg->som);
        es->when = date; // user-visible date
        es->sid  = s->uniq_id;
        es->srv  = s->srv;