]> Savannah Git Hosting - gnulib.git/commitdiff
Avoid -Wformat=security failures with --disable-nls
authorPádraig Brady <P@draigBrady.com>
Fri, 17 Jan 2025 13:01:40 +0000 (13:01 +0000)
committerBruno Haible <bruno@clisp.org>
Sun, 2 Feb 2025 09:51:36 +0000 (10:51 +0100)
This was noticed with GCC 14.

* lib/xmemcoll.c: Always use format arguments.
* lib/xprintf.c: Likewise.

ChangeLog
lib/xmemcoll.c
lib/xprintf.c

index ae9cbae8a4ec1263a3742edf05faff707bc04cb2..88e92dde5791347526f5552e38ad6810e5fec2d8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2025-01-17  Pádraig Brady  <P@draigBrady.com>
+
+       Avoid -Wformat=security failures with --disable-nls
+       This was noticed with GCC 14.
+       * lib/xmemcoll.c: Always use format arguments.
+       * lib/xprintf.c: Likewise.
+
 2025-01-16  Bruno Haible  <bruno@clisp.org>
 
        getopt-posix: Fix compilation error in C++ mode (regression 2024-09-21).
index 52a1b9149ee678a58754a003e6a41e5c61428a39..5550fe7375d92024b23ce2948552355a3645082e 100644 (file)
@@ -1,6 +1,6 @@
 /* Locale-specific memory comparison.
 
-   Copyright (C) 2002-2004, 2006, 2009-2024 Free Software Foundation, Inc.
+   Copyright (C) 2002-2004, 2006, 2009-2025 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -36,8 +36,8 @@ collate_error (int collation_errno,
                char const *s1, size_t s1len,
                char const *s2, size_t s2len)
 {
-  error (0, collation_errno, _("string comparison failed"));
-  error (0, 0, _("Set LC_ALL='C' to work around the problem."));
+  error (0, collation_errno, "%s", _("string comparison failed"));
+  error (0, 0, "%s", _("Set LC_ALL='C' to work around the problem."));
   error (exit_failure, 0,
          _("The strings compared were %s and %s."),
          quotearg_n_style_mem (0, locale_quoting_style, s1, s1len),
index 1957131f49c68fb6261bb3b53d5f971721beb1ae..4ed29bfcc9981b80b1ff7368e29e37affc9389aa 100644 (file)
@@ -1,5 +1,5 @@
 /* printf wrappers that fail immediately for non-file-related errors
-   Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009-2025 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -47,7 +47,7 @@ xvprintf (char const *restrict format, va_list args)
 {
   int retval = vprintf (format, args);
   if (retval < 0 && ! ferror (stdout))
-    error (exit_failure, errno, gettext ("cannot perform formatted output"));
+    error (exit_failure, errno, "%s", gettext ("cannot perform formatted output"));
 
   return retval;
 }
@@ -73,7 +73,7 @@ xvfprintf (FILE *restrict stream, char const *restrict format, va_list args)
 {
   int retval = vfprintf (stream, format, args);
   if (retval < 0 && ! ferror (stream))
-    error (exit_failure, errno, gettext ("cannot perform formatted output"));
+    error (exit_failure, errno, "%s", gettext ("cannot perform formatted output"));
 
   return retval;
 }