This fix works at least in my tests. And it turned out to be a bit more complex than I thought, and it was on the loading side after all.
- ML
From 56d18b3c06e3c3b61908da30ab130d62f3e0e85d Mon Sep 17 00:00:00 2001 From: Marko Lindqvist <cazf...@gmail.com> Date: Mon, 27 Nov 2023 01:29:52 +0200 Subject: [PATCH] Reserve space for terminating NULL on astr_buffer Growing the buffer was always considered a failure, as it was one byte too small even after giving out the requested size. Reported by Giacomo Mulas Debian Bug#1056916 Signed-off-by: Marko Lindqvist <cazf...@gmail.com>< --- utility/astring.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utility/astring.c b/utility/astring.c index 44d39f582c..cfcb67565f 100644 --- a/utility/astring.c +++ b/utility/astring.c @@ -234,8 +234,8 @@ static inline void astr_vadd_at(struct astring *astr, size_t at, va_copy(copy, ap); req_len = fc_vsnprintf(buffer, buffer_size, format, ap); - if (req_len > buffer_size) { - buffer = astr_buffer_grow(req_len, &buffer_size); + if (req_len + 1 > buffer_size) { + buffer = astr_buffer_grow(req_len + 1, &buffer_size); /* Even if buffer is *still* too small, we fill what we can */ req_len = fc_vsnprintf(buffer, buffer_size, format, copy); if (req_len > buffer_size) { -- 2.42.0