]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[CLEANUP] buffers: wrong size calculation for displaced data
authorWilly Tarreau <w@1wt.eu>
Mon, 28 Dec 2009 17:37:54 +0000 (18:37 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 28 Jan 2010 22:16:27 +0000 (23:16 +0100)
This error was triggered by requests not starting at the beginning
of the buffer. It cannot happen with earlier versions though it might
be a good idea to fix it anyway.
(cherry picked from commit 019fd5bc932e2527c4a7bf196903aa1055537c1f)

src/buffers.c

index c8681cfb8c6487153fec8cfa96bca8c603bb025f..0de88fcfe905d6777f21a6ab29448a315d7f9485 100644 (file)
@@ -115,7 +115,7 @@ int buffer_replace(struct buffer *b, char *pos, char *end, const char *str)
                return 0;  /* no space left */
 
        /* first, protect the end of the buffer */
-       memmove(end + delta, end, b->data + b->l - end);
+       memmove(end + delta, end, b->r - end);
 
        /* now, copy str over pos */
        memcpy(pos, str,len);
@@ -155,7 +155,7 @@ int buffer_replace2(struct buffer *b, char *pos, char *end, const char *str, int
        }
 
        /* first, protect the end of the buffer */
-       memmove(end + delta, end, b->data + b->l - end);
+       memmove(end + delta, end, b->r - end);
 
        /* now, copy str over pos */
        if (len)
@@ -196,7 +196,7 @@ int buffer_insert_line2(struct buffer *b, char *pos, const char *str, int len)
                return 0;  /* no space left */
 
        /* first, protect the end of the buffer */
-       memmove(pos + delta, pos, b->data + b->l - pos);
+       memmove(pos + delta, pos, b->r - pos);
 
        /* now, copy str over pos */
        if (len && str) {