Seen on GCC 14:
  getlimits.c:73:3: warning: stack-based buffer overflow [CWE-121] \
     [-Wanalyzer-out-of-bounds]
     73 |   sprintf (limit + 1, "%" "ju", (uintmax_t) TYPE##_MAX);     \
        |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
... while limit is defined more than large enough.

* find/getlimits.c: Add pragma for GCC version >= 14.
---
 find/getlimits.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/find/getlimits.c b/find/getlimits.c
index ee0b351f..201a02b1 100644
--- a/find/getlimits.c
+++ b/find/getlimits.c
@@ -38,6 +38,11 @@
 # define MIN(a,b) (a<b?a:b)
 #endif

+/* Silence GCC 14.  */
+#if 14 <= __GNUC__
+# pragma GCC diagnostic ignored "-Wanalyzer-out-of-bounds"
+#endif
+
 /* Add one to the absolute value of the number whose textual
    representation is BUF + 1.  Do this in-place, in the buffer.
    Return a pointer to the result, which is normally BUF + 1, but is
--
2.47.1


Reply via email to