From: Willy Tarreau Date: Mon, 15 Apr 2024 06:31:01 +0000 (+0200) Subject: MINOR: ring: always check that the old ring fits in the new one in ring_dup() X-Git-Tag: v3.0-dev8~53 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4615cb510cb44bb02abe165881dc7020a17b8b78;p=thirdparty%2Fhaproxy.git MINOR: ring: always check that the old ring fits in the new one in ring_dup() Let's add a BUG_ON() to make sure we don't accidentally shrink a buffer. --- diff --git a/include/haproxy/ring.h b/include/haproxy/ring.h index f8c3a52b63..307b2887c4 100644 --- a/include/haproxy/ring.h +++ b/include/haproxy/ring.h @@ -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;