From 194fb6177e07f13d7c222f21b8880bdfb0ed8f15 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 22 Dec 2023 15:09:25 +0200 Subject: [PATCH] freeciv-3.0: Backport savegame loading fix Signed-off-by: Marko Lindqvist --- ...-for-terminating-NULL-on-astr_buffer.patch | 36 +++++++++++++++++++ recipes-games/freeciv/freeciv_3.0.9.bb | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 recipes-games/freeciv/freeciv/0002-Reserve-space-for-terminating-NULL-on-astr_buffer.patch diff --git a/recipes-games/freeciv/freeciv/0002-Reserve-space-for-terminating-NULL-on-astr_buffer.patch b/recipes-games/freeciv/freeciv/0002-Reserve-space-for-terminating-NULL-on-astr_buffer.patch new file mode 100644 index 0000000..ca7fa67 --- /dev/null +++ b/recipes-games/freeciv/freeciv/0002-Reserve-space-for-terminating-NULL-on-astr_buffer.patch @@ -0,0 +1,36 @@ +From 03df29aaa12892b851d13f291977be3e7679e560 Mon Sep 17 00:00:00 2001 +From: Marko Lindqvist +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 < +--- + 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 + diff --git a/recipes-games/freeciv/freeciv_3.0.9.bb b/recipes-games/freeciv/freeciv_3.0.9.bb index 9463374..32d9acb 100644 --- a/recipes-games/freeciv/freeciv_3.0.9.bb +++ b/recipes-games/freeciv/freeciv_3.0.9.bb @@ -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" -