> 2025-09-16  Bruno Haible  <[email protected]>
> 
>       strerror_r: Ensure a trailing NUL when truncating.
>       * lib/strerror_r.c (strerror_r): Fix use of snprintf.
> 

Oops. While this patch fixed the behaviour on mingw 5, it broke it
on mingw 13 (with -D__USE_MINGW_ANSI_STDIO=0). This patch should now
fix it for both:


2025-09-16  Bruno Haible  <[email protected]>

        strerror_r-posix: Fix truncation code (regression today).
        * lib/strerror_r.c (strerror_r): Fix use of snprintf again.

diff --git a/lib/strerror_r.c b/lib/strerror_r.c
index b67684ebe6..1e6974e327 100644
--- a/lib/strerror_r.c
+++ b/lib/strerror_r.c
@@ -450,9 +450,9 @@ strerror_r (int errnum, char *buf, size_t buflen)
 #endif
 #if defined __HAIKU__
         /* For consistency with perror().  */
-        snprintf (buf, buflen - 1, "Unknown Application Error (%d)", errnum);
+        snprintf (buf, buflen, "Unknown Application Error (%d)", errnum);
 #else
-        snprintf (buf, buflen - 1, "Unknown error %d", errnum);
+        snprintf (buf, buflen, "Unknown error %d", errnum);
 #endif
         buf[buflen - 1] = '\0';
       }




Reply via email to