Skip to contentSkip to conversation

package/safeclib: fix build with gcc-14.x

PATCH Applied Bernd Kuhls 2 participants 5 messages Jan 10 – Feb 13

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 package/safeclib: fix build with gcc-14.x

Backported two upstream patches to fix build errors introduced by the bump of gcc to 14.x.

Renamed patch 0001 to prepare its removal with the upcoming version bump of safelib, added Upstream: tag.

Fixes:
https://autobuild.buildroot.net/results/af6/af65e6386439098ddf706ca43e99320cf5e9fd80/

---
 .checkpackageignore                           |  1 -
 ...snprintf_s-Increase-Buffer-Size-by-1.patch | 51 +++++++++++++++++++
 ...snprintf_s-Increase-Buffer-Size-by-1.patch | 49 ++++++++++++++++++
 ...3-fix-armv7-asm-inline-error-GH-115.patch} |  4 +-
 4 files changed, 102 insertions(+), 3 deletions(-)
 create mode 100644 package/safeclib/0001-vsnprintf_s-Increase-Buffer-Size-by-1.patch
 create mode 100644 package/safeclib/0002-vsnprintf_s-Increase-Buffer-Size-by-1.patch
 rename package/safeclib/{0001-fix-armv7-asm-inline-error-GH-115.patch => 0003-fix-armv7-asm-inline-error-GH-115.patch} (98%)
.checkpackageignore +0 -1
index ad02938884..2502803da3 100644
@@ -873,7 +873,6 @@ package/rubix/0001-dont-use-legacy-functions.patch lib_patch.Upstream
 package/rubix/0002-misc-fixes.patch lib_patch.Sob lib_patch.Upstream
 package/rygel/S99rygel Shellcheck lib_sysv.Indent lib_sysv.Variables
 package/s6-linux-init/0001-configure-add-D_GNU_SOURCE.patch lib_patch.Upstream
-package/safeclib/0001-fix-armv7-asm-inline-error-GH-115.patch lib_patch.Upstream
 package/samba4/0001-build-find-pre-built-heimdal-build-tools-in-case-of-.patch lib_patch.Upstream
 package/samba4/0002-ldap_message_test.c-include-stdint.h-before-cmoka.h.patch lib_patch.Upstream
 package/samba4/S91smb Shellcheck lib_sysv.Indent lib_sysv.Variables
package/safeclib/0001-vsnprintf_s-Increase-Buffer-Size-by-1.patch new file +51 -0

51 lines not on this page · raw message

package/safeclib/0002-vsnprintf_s-Increase-Buffer-Size-by-1.patch new file +49 -0

49 lines not on this page · raw message

package/safeclib/0003-fix-armv7-asm-inline-error-GH-115.patch renamed from package/safeclib/0001-fix-armv7-asm-inline-error-GH-115.patch +2 -2
similarity index 98%
rename from package/safeclib/0001-fix-armv7-asm-inline-error-GH-115.patch
rename to package/safeclib/0003-fix-armv7-asm-inline-error-GH-115.patch
index 3cb37b96f5..bf14812318 100644
@@ -7,8 +7,8 @@ some armv7 buildroot variants fail on asm.
 we already probe for that, so use it.
 Fixes GH #115
 
-[Retrieved from:
-https://github.com/rurban/safeclib/commit/9c739800a8915d5f2a73c840190920e95ffa1c5c]
+Upstream: https://github.com/rurban/safeclib/commit/9c739800a8915d5f2a73c840190920e95ffa1c5c
+
 Signed-off-by: Fabrice Fontaine <[email protected]>
 ---
  tests/perf_private.h | 49 +++++++++++++++++++++++++-------------------
Signature · 6 lines
2.47.3

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH 2/2 package/safeclib: bump version to 3.9.1

https://github.com/rurban/safeclib/blob/v3.9.1/ChangeLog

Removed backports from patches 0001 & 0002.

Removed patch 0003 which is included in this release.

---
 ...snprintf_s-Increase-Buffer-Size-by-1.patch |   9 +-
 ...snprintf_s-Increase-Buffer-Size-by-1.patch |  15 +-
 ...03-fix-armv7-asm-inline-error-GH-115.patch | 156 ------------------
 package/safeclib/safeclib.hash                |   4 +-
 package/safeclib/safeclib.mk                  |   2 +-
 5 files changed, 14 insertions(+), 172 deletions(-)
 delete mode 100644 package/safeclib/0003-fix-armv7-asm-inline-error-GH-115.patch
package/safeclib/0001-vsnprintf_s-Increase-Buffer-Size-by-1.patch +4 -5
index eae11dcc0d..c744e043d9 100644
@@ -27,20 +27,19 @@ cc1: all warnings being treated as errors
 
 Upstream: https://github.com/rurban/safeclib/pull/150
 
-[backported to version 3.7.1]
 Signed-off-by: Bernd Kuhls <[email protected]>
 ---
  src/str/vsnprintf_s.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/src/str/vsnprintf_s.c b/src/str/vsnprintf_s.c
-index 59dbda94..ca838df1 100644
+index 0b62c3cb..cf8e866e 100644
 --- a/src/str/vsnprintf_s.c
 +++ b/src/str/vsnprintf_s.c
-@@ -296,7 +296,7 @@ static size_t safec_ntoa_long(out_fct_type out,  const char *funcname,
+@@ -309,7 +309,7 @@ static size_t safec_ntoa_long(out_fct_type out, const char *funcname,
+                               unsigned long value, bool negative,
                                unsigned long base, unsigned int prec,
-                               unsigned int width, unsigned int flags)
- {
+                               unsigned int width, unsigned int flags) {
 -    char buf[PRINTF_NTOA_BUFFER_SIZE];
 +    char buf[PRINTF_NTOA_BUFFER_SIZE + 1];
      size_t len = 0U;
package/safeclib/0002-vsnprintf_s-Increase-Buffer-Size-by-1.patch +7 -8
index 2dabebf3b2..13d0cc71f5 100644
@@ -25,23 +25,22 @@ Signed-off-by: Khem Raj <[email protected]>
 
 Upstream: https://github.com/rurban/safeclib/commit/f59a0c8c1b5cf19cd0ed7f9bfb3a1e85f54113d0
 
-[backported to version 3.7.1]
 Signed-off-by: Bernd Kuhls <[email protected]>
 ---
  src/str/vsnprintf_s.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/src/str/vsnprintf_s.c b/src/str/vsnprintf_s.c
-index ca838df1..8ef6989a 100644
+index fa53ab42..0b62c3cb 100644
 --- a/src/str/vsnprintf_s.c
 +++ b/src/str/vsnprintf_s.c
-@@ -369,7 +369,7 @@ static size_t safec_ftoa(out_fct_type out,  const char *funcname,
-                          double value, unsigned int prec, unsigned int width,
-                          unsigned int flags)
- {
+@@ -391,7 +391,7 @@ static size_t safec_ftoa(out_fct_type out, const char *funcname, char *buffer,
+                          size_t idx, size_t maxlen, double value,
+                          unsigned int prec, unsigned int width,
+                          unsigned int flags) {
 -    char buf[PRINTF_FTOA_BUFFER_SIZE];
-+    char buf[PRINTF_FTOA_BUFFER_SIZE + 1];
-     size_t len = 0U;
++    char buf[PRINTF_FTOA_BUFFER_SIZE + 1]; // Add extra byte for safety
+     size_t len = 0U, off = 0U;
      double tmp;
      double diff = 0.0;
 -- 
package/safeclib/0003-fix-armv7-asm-inline-error-GH-115.patch deleted +0 -156

156 lines not on this page · raw message

package/safeclib/safeclib.hash +2 -2
index bca5d86261..0227ff2837 100644
@@ -1,5 +1,5 @@
-# From https://github.com/rurban/safeclib/releases/tag/v3.7.1
-sha256  71d3ec970f930bd980f2a41127228eeedfc53749e4c6b203329adc4ff7df32a7  safeclib-3.7.1.tar.xz
+# From https://github.com/rurban/safeclib/releases/tag/v3.9.1
+sha256  771b8de483c4f48c90c12bc2c0326571d3d094440ca29008e4cf70562c631c67  safeclib-3.9.1.tar.xz
 
 # Hash for license file
 sha256  c33e77efd5781e3d59a2bb648c82d2a615035ef0d24cf58880380e3af906510b  COPYING
package/safeclib/safeclib.mk +1 -1
index bc58c1a38c..6478796a7e 100644
@@ -4,7 +4,7 @@
 #
 ################################################################################
 
-SAFECLIB_VERSION = 3.7.1
+SAFECLIB_VERSION = 3.9.1
 SAFECLIB_SITE = \
 	https://github.com/rurban/safeclib/releases/download/v$(SAFECLIB_VERSION)
 SAFECLIB_SOURCE = safeclib-$(SAFECLIB_VERSION).tar.xz
Signature · 6 lines
2.47.3

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

Re: [Buildroot] [PATCH 2/2] package/safeclib: bump version to 3.9.1

Quoted 7 lines · Bernd Kuhls

https://github.com/rurban/safeclib/blob/v3.9.1/ChangeLog

Removed backports from patches 0001 & 0002.

Removed patch 0003 which is included in this release.

Applied, thanks!

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw
In reply to Bernd Kuhls
Quoted 5 lines · Bernd Kuhls

Backported two upstream patches to fix build errors introduced by the bump of gcc to 14.x.

Renamed patch 0001 to prepare its removal with the upcoming version bump of safelib, added Upstream: tag.

Adding the Upstream: tag in 0001 should have been a separate patch, so I split that up. Also the renaming didn't make a lot of sense, so I kept the same file name.

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#4 lore raw
In reply to Bernd Kuhls

In reply of:

Quoted 10 lines

Backported two upstream patches to fix build errors introduced by the bump of gcc to 14.x.

Renamed patch 0001 to prepare its removal with the upcoming version bump of safelib, added Upstream: tag.

Fixes:
https://autobuild.buildroot.net/results/af6/af65e6386439098ddf706ca43e99320cf5e9fd80/

Applied to 2025.02.x & 2025.11.x. Thanks

Quoted 159 lines
---
 .checkpackageignore                           |  1 -
 ...snprintf_s-Increase-Buffer-Size-by-1.patch | 51 +++++++++++++++++++
 ...snprintf_s-Increase-Buffer-Size-by-1.patch | 49 ++++++++++++++++++
 ...3-fix-armv7-asm-inline-error-GH-115.patch} |  4 +-
 4 files changed, 102 insertions(+), 3 deletions(-)
 create mode 100644 package/safeclib/0001-vsnprintf_s-Increase-Buffer-Size-by-1.patch
 create mode 100644 package/safeclib/0002-vsnprintf_s-Increase-Buffer-Size-by-1.patch
 rename package/safeclib/{0001-fix-armv7-asm-inline-error-GH-115.patch => 0003-fix-armv7-asm-inline-error-GH-115.patch} (98%)
.checkpackageignore +0 -1
index ad02938884..2502803da3 100644
@@ -873,7 +873,6 @@ package/rubix/0001-dont-use-legacy-functions.patch lib_patch.Upstream
 package/rubix/0002-misc-fixes.patch lib_patch.Sob lib_patch.Upstream
 package/rygel/S99rygel Shellcheck lib_sysv.Indent lib_sysv.Variables
 package/s6-linux-init/0001-configure-add-D_GNU_SOURCE.patch lib_patch.Upstream
-package/safeclib/0001-fix-armv7-asm-inline-error-GH-115.patch lib_patch.Upstream
 package/samba4/0001-build-find-pre-built-heimdal-build-tools-in-case-of-.patch lib_patch.Upstream
 package/samba4/0002-ldap_message_test.c-include-stdint.h-before-cmoka.h.patch lib_patch.Upstream
 package/samba4/S91smb Shellcheck lib_sysv.Indent lib_sysv.Variables
package/safeclib/0001-vsnprintf_s-Increase-Buffer-Size-by-1.patch new file +51 -0
new file mode 100644
index 0000000000..eae11dcc0d
@@ -0,0 +1,51 @@
+From 62051f9761f92dc99c8ce0552239ad10e2062168 Mon Sep 17 00:00:00 2001
+From: Bernd Kuhls <[email protected]>
+Date: Sat, 10 Jan 2026 12:16:22 +0100
+Subject: [PATCH] vsnprintf_s: Increase Buffer Size by 1
+
+Another fix similar to https://github.com/rurban/safeclib/commit/f59a0c8c1b5cf19cd0ed7f9bfb3a1e85f54113d0
+
+In function 'safec_ntoa_format',
+    inlined from 'safec_ntoa_long' at str/vsnprintf_s.c:331:12:
+str/vsnprintf_s.c:256:24: error: writing 32 bytes into a region of size 0 [-Werror=stringop-overflow=]
+  256 |             buf[len++] = '0';
+      |             ~~~~~~~~~~~^~~~~
+str/vsnprintf_s.c: In function 'safec_ntoa_long':
+str/vsnprintf_s.c:312:10: note: at offset 32 into destination object 'buf' of size 32
+  312 |     char buf[PRINTF_NTOA_BUFFER_SIZE];
+      |          ^~~
+In function 'safec_ntoa_format',
+    inlined from 'safec_ntoa_long' at str/vsnprintf_s.c:331:12:
+str/vsnprintf_s.c:260:24: error: writing 32 bytes into a region of size 0 [-Werror=stringop-overflow=]
+  260 |             buf[len++] = '0';
+      |             ~~~~~~~~~~~^~~~~
+str/vsnprintf_s.c: In function 'safec_ntoa_long':
+str/vsnprintf_s.c:312:10: note: at offset 32 into destination object 'buf' of size 32
+  312 |     char buf[PRINTF_NTOA_BUFFER_SIZE];
+      |          ^~~
+cc1: all warnings being treated as errors
+
+Upstream: https://github.com/rurban/safeclib/pull/150
+
+[backported to version 3.7.1]
+Signed-off-by: Bernd Kuhls <[email protected]>
+---
+ src/str/vsnprintf_s.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/str/vsnprintf_s.c b/src/str/vsnprintf_s.c
+index 59dbda94..ca838df1 100644
+--- a/src/str/vsnprintf_s.c
++++ b/src/str/vsnprintf_s.c
+@@ -296,7 +296,7 @@ static size_t safec_ntoa_long(out_fct_type out,  const char *funcname,
+                               unsigned long base, unsigned int prec,
+                               unsigned int width, unsigned int flags)
+ {
+-    char buf[PRINTF_NTOA_BUFFER_SIZE];
++    char buf[PRINTF_NTOA_BUFFER_SIZE + 1];
+     size_t len = 0U;
+ 
+     // no hash for 0 values
+-- 
+2.47.3
+
package/safeclib/0002-vsnprintf_s-Increase-Buffer-Size-by-1.patch new file +49 -0
new file mode 100644
index 0000000000..2dabebf3b2
@@ -0,0 +1,49 @@
+From dea3c2e1aa1b775baa690b9ef40239f881c5f068 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Wed, 13 Aug 2025 20:23:48 -0700
+Subject: [PATCH] vsnprintf_s: Increase Buffer Size by 1
+
+It is a buffer overflow warning that GCC 15.2 is catching.
+The issue is that it's trying to write to `buf[len++]` when len could
+potentially be 31, which would write to buf[31] in a buffer of size 32
+(valid indices 0-31), but the len++ post-increment means it could
+theoretically write beyond the buffer bounds.
+
+Fixes
+
+../../sources/safec-3.9.1/src/str/vsnprintf_s.c: In function 'safec_ftoa.isra':
+../../sources/safec-3.9.1/src/str/vsnprintf_s.c:523:24: error: writing 32 bytes into a region of size 31 [-Werror=stringop-overflow=]
+  523 |             buf[len++] = '0';
+      |             ~~~~~~~~~~~^~~~~
+../../sources/safec-3.9.1/src/str/vsnprintf_s.c:394:10: note: at offset [1, 32] into destination object 'buf' of size 32
+  394 |     char buf[PRINTF_FTOA_BUFFER_SIZE];
+      |          ^~~
+cc1: all warnings being treated as errors
+
+Upstream-Status: Submitted [https://github.com/rurban/safeclib/pull/148]
+Signed-off-by: Khem Raj <[email protected]>
+
+Upstream: https://github.com/rurban/safeclib/commit/f59a0c8c1b5cf19cd0ed7f9bfb3a1e85f54113d0
+
+[backported to version 3.7.1]
+Signed-off-by: Bernd Kuhls <[email protected]>
+---
+ src/str/vsnprintf_s.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/str/vsnprintf_s.c b/src/str/vsnprintf_s.c
+index ca838df1..8ef6989a 100644
+--- a/src/str/vsnprintf_s.c
++++ b/src/str/vsnprintf_s.c
+@@ -369,7 +369,7 @@ static size_t safec_ftoa(out_fct_type out,  const char *funcname,
+                          double value, unsigned int prec, unsigned int width,
+                          unsigned int flags)
+ {
+-    char buf[PRINTF_FTOA_BUFFER_SIZE];
++    char buf[PRINTF_FTOA_BUFFER_SIZE + 1];
+     size_t len = 0U;
+     double tmp;
+     double diff = 0.0;
+-- 
+2.47.3
+
package/safeclib/0003-fix-armv7-asm-inline-error-GH-115.patch renamed from package/safeclib/0001-fix-armv7-asm-inline-error-GH-115.patch +2 -2
similarity index 98%
rename from package/safeclib/0001-fix-armv7-asm-inline-error-GH-115.patch
rename to package/safeclib/0003-fix-armv7-asm-inline-error-GH-115.patch
index 3cb37b96f5..bf14812318 100644
@@ -7,8 +7,8 @@ some armv7 buildroot variants fail on asm.
 we already probe for that, so use it.
 Fixes GH #115
 
-[Retrieved from:
-https://github.com/rurban/safeclib/commit/9c739800a8915d5f2a73c840190920e95ffa1c5c]
+Upstream: https://github.com/rurban/safeclib/commit/9c739800a8915d5f2a73c840190920e95ffa1c5c
+
 Signed-off-by: Fabrice Fontaine <[email protected]>
 ---
  tests/perf_private.h | 49 +++++++++++++++++++++++++-------------------
Signature · 6 lines
2.47.3

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot