> * lib/openat-die.c (_): Likewise.
The change to openat-die.c triggers a new warning in gzip, from the gcc 13
options
-Wformat -Wformat-security
Since this package's "make distcheck" enables -Werror, it even triggers an
error:
$ make distcheck
...
CC libgzip_a-openat-die.o
openat-die.c: In function 'openat_save_fail':
openat-die.c:37:3: error: format not a string literal and no format arguments
[-Werror=format-security]
37 | error (exit_failure, errnum,
| ^~~~~
openat-die.c:37:3: error: format not a string literal and no format arguments
[-Werror=format-security]
openat-die.c: In function 'openat_restore_fail':
openat-die.c:56:3: error: format not a string literal and no format arguments
[-Werror=format-security]
56 | error (exit_failure, errnum,
| ^~~~~
openat-die.c:56:3: error: format not a string literal and no format arguments
[-Werror=format-security]
cc1: all warnings being treated as errors
make[6]: *** [Makefile:3281: libgzip_a-openat-die.o] Error 1
The warning is pointless, since the gettext tools make sure that the localized
variant of the string will not access nonexistent format arguments. Thus, it's
only a code style warning, misplaced under the umbrella of "security".
Anyway, it's easy to fix.
2024-12-10 Bruno Haible <[email protected]>
openat-die: Fix a gcc -Wformat -Wformat-security warning.
* lib/openat-die.c (openat_save_fail, openat_restore_fail): Put the
internationalized error message into non-format-string position.
diff --git a/lib/openat-die.c b/lib/openat-die.c
index 403ca4ff7c..022109b433 100644
--- a/lib/openat-die.c
+++ b/lib/openat-die.c
@@ -34,7 +34,7 @@ _Noreturn void
openat_save_fail (int errnum)
{
#ifndef GNULIB_LIBPOSIX
- error (exit_failure, errnum,
+ error (exit_failure, errnum, "%s",
_("unable to record current working directory"));
#endif
/* _Noreturn cannot be applied to error, since it returns
@@ -53,7 +53,7 @@ _Noreturn void
openat_restore_fail (int errnum)
{
#ifndef GNULIB_LIBPOSIX
- error (exit_failure, errnum,
+ error (exit_failure, errnum, "%s",
_("failed to return to initial working directory"));
#endif