]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: ring: always check that the old ring fits in the new one in ring_dup()
authorWilly Tarreau <w@1wt.eu>
Mon, 15 Apr 2024 06:31:01 +0000 (08:31 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 15 Apr 2024 06:31:01 +0000 (08:31 +0200)
Let's add a BUG_ON() to make sure we don't accidentally shrink a buffer.

include/haproxy/ring.h

index f8c3a52b634bea479a5ea04ac7bacf1f9222c558..307b2887c44e5f22d471bdbc4a8451bdbe43ccd6 100644 (file)
@@ -102,6 +102,8 @@ static inline size_t ring_dup(struct ring *dst, const struct ring *src, size_t m
        if (max > ring_data(src))
                max = ring_data(src);
 
+       BUG_ON(max > ring_size(dst));
+
        vp_peek_ofs(v1, v2, 0, ring_area(dst), max);
        dst->storage->head = 0;
        dst->storage->tail = max;