]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: http: error snapshots are wrong if buffer wraps
authorWilly Tarreau <w@1wt.eu>
Tue, 8 May 2012 06:54:15 +0000 (08:54 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 8 May 2012 19:28:15 +0000 (21:28 +0200)
Commit 81f2fb added support for wrapping buffer captures, but unfortunately
the code used to perform two memcpy() over the same destination, causing a
loss of the start of the buffer rendering some error snapshots unusable.

This bug is present in 1.4 too and must be backported.

src/proto_http.c

index 2c1ff566cf569abbb95a907797f23161144288f0..922ff61aba3d12a529553ddcde25cff5e2e7a47a 100644 (file)
@@ -7227,7 +7227,7 @@ void http_capture_bad_message(struct error_snapshot *es, struct session *s,
                es->len = bi_end(buf) - (buf->p + msg->som) + buf->size;
                memcpy(es->buf, buf->p + msg->som, MIN(len1, sizeof(es->buf)));
                if (es->len > len1 && len1 < sizeof(es->buf))
-                       memcpy(es->buf, buf->data, MIN(es->len, sizeof(es->buf)) - len1);
+                       memcpy(es->buf + len1, buf->data, MIN(es->len, sizeof(es->buf)) - len1);
        }
        else {
                es->len = bi_end(buf) - (buf->p + msg->som);