freeciv-3.0: Backport savegame loading fix

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
This commit is contained in:
Marko Lindqvist
2023-12-22 15:09:25 +02:00
parent c87425f298
commit 194fb6177e
2 changed files with 37 additions and 1 deletions

View File

@@ -0,0 +1,36 @@
From 03df29aaa12892b851d13f291977be3e7679e560 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Mon, 27 Nov 2023 01:29:52 +0200
Subject: [PATCH 2/3] 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 <cazfi74@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

View File

@@ -5,7 +5,7 @@ SRC_URI += "\
${SOURCEFORGE_MIRROR}/freeciv/freeciv-${PV}.tar.xz \
file://allow-root.patch \
file://dummy-qtver.patch \
file://0002-Reserve-space-for-terminating-NULL-on-astr_buffer.patch \
"
SRC_URI[sha256sum] = "16c46a9c378b4a511c1e3d3a7c435a78230a432d8b852202aaf5d5d584962742"