]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: shctx: forbid shctx to read more than expected
authorWilliam Lallemand <wlallemand@haproxy.com>
Tue, 31 Oct 2017 19:21:46 +0000 (20:21 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 31 Oct 2017 20:17:19 +0000 (21:17 +0100)
Forbid shctx to read more than expected, it allows you to use a greater
value as a len with shctx_row_data_get(), the size of the destination
buffer for example.

src/shctx.c

index 69da33570d78288b4aeee289ef6b9f264abc04ae..61fd12d3d61823d4cecf0305e1e9069f14d473e3 100644 (file)
@@ -209,6 +209,10 @@ int shctx_row_data_get(struct shared_context *shctx, struct shared_block *first,
        int count = 0, size = 0, start = -1;
        struct shared_block *block;
 
+       /* can't copy more */
+       if (len > first->len)
+               len = first->len;
+
        block = first;
        count = 0;
        /* Pass through the blocks to copy them */