From: Pádraig Brady
Date: Fri, 17 Jan 2025 13:01:40 +0000 (+0000)
Subject: Avoid -Wformat=security failures with --disable-nls
X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=2481e7a50d6535582856626b53009f419e2e05e2;p=gnulib.git
Avoid -Wformat=security failures with --disable-nls
This was noticed with GCC 14.
* lib/xmemcoll.c: Always use format arguments.
* lib/xprintf.c: Likewise.
---
diff --git a/ChangeLog b/ChangeLog
index 8a77ff50a8..f80d7579c0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2025-01-17 Pádraig Brady
+
+ 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 Paul Eggert
crc-x86_64: fix unaligned access
diff --git a/lib/xmemcoll.c b/lib/xmemcoll.c
index d1b141c9e0..c0ac7c4863 100644
--- a/lib/xmemcoll.c
+++ b/lib/xmemcoll.c
@@ -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),
diff --git a/lib/xprintf.c b/lib/xprintf.c
index 790af5320b..4d9a3e5e4d 100644
--- a/lib/xprintf.c
+++ b/lib/xprintf.c
@@ -45,7 +45,7 @@ xvprintf (char const *restrict format, va_list args)
{
off64_t retval = vzprintf (format, args);
if (retval < 0 && ! ferror (stdout))
- error (exit_failure, errno, _("cannot perform formatted output"));
+ error (exit_failure, errno, "%s", _("cannot perform formatted output"));
return retval;
}
@@ -67,7 +67,7 @@ xvfprintf (FILE *restrict stream, char const *restrict format, va_list args)
{
off64_t retval = vfzprintf (stream, format, args);
if (retval < 0 && ! ferror (stream))
- error (exit_failure, errno, _("cannot perform formatted output"));
+ error (exit_failure, errno, "%s", _("cannot perform formatted output"));
return retval;
}