From b1111e2a181a295f05d62ac9cbcf3c91fe1d0b00 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Mon, 24 Mar 2025 18:11:36 +0000 Subject: [PATCH] buffer: Don't allow to resize the buffer smaller than what it holds Signed-off-by: Michael Tremer --- src/pakfire/buffer.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pakfire/buffer.c b/src/pakfire/buffer.c index a21ecd9b..3c11e8d9 100644 --- a/src/pakfire/buffer.c +++ b/src/pakfire/buffer.c @@ -76,6 +76,10 @@ static int pakfire_buffer_resize(struct pakfire_buffer* self, size_t length) { if (self->max_length && (length > self->max_length)) return -ENOBUFS; + // Don't make the buffer smaller than the used space + if (length < self->used) + return -EINVAL; + // Round up to the nearest chunk size length = pakfire_buffer_align(self, length); -- 2.39.5