Hello Gnulib people.

A user suggests changing

   error (exit_failure, errnum,
         _("failed to return to initial working directory"));

to

   error (exit_failure, errnum,
         "%s", _("unable to record current working directory"));

(twice) in openat-die.c, in order to silence a clang warning.  I see
that the latest Gnulib is still without the format string.  What do you
think?

Thanks,

--- Begin Message ---
From: Wang Mingyu <[email protected]>

When building with clang and -Werror=format-security, compilation
fails with:

  openat-die.c:38:10: error: format string is not a string literal
  (potentially insecure) [-Werror,-Wformat-security]

Fix this by using "%s" as the format string and passing the
translated message as an argument to error().

Signed-off-by: Wang Mingyu <[email protected]>
---
 jitter/gnulib-local/openat-die.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/jitter/gnulib-local/openat-die.c b/jitter/gnulib-local/openat-die.c
index d37e399..f4b3301 100644
--- a/jitter/gnulib-local/openat-die.c
+++ b/jitter/gnulib-local/openat-die.c
@@ -35,7 +35,7 @@ openat_save_fail (int errnum)
 {
 #ifndef GNULIB_LIBPOSIX
   error (exit_failure, errnum,
-         _("unable to record current working directory"));
+         "%s", _("unable to record current working directory"));
 #endif
   /* _Noreturn cannot be applied to error, since it returns
      when its first argument is 0.  To help compilers understand that this
@@ -54,7 +54,7 @@ openat_restore_fail (int errnum)
 {
 #ifndef GNULIB_LIBPOSIX
   error (exit_failure, errnum,
-         _("failed to return to initial working directory"));
+         "%s", _("failed to return to initial working directory"));
 #endif
 
   /* As above.  */
-- 
2.43.0



--- End Message ---
-- 
Luca Saiu      https://ageinghacker.net
  GNU Jitter     https://www.gnu.org/software/jitter
  GNU epsilon    https://www.gnu.org/software/epsilon
  pEp-mail-tool  https://codeberg.org/pEp/pEp-mail-tool

I support everyone's freedom of mocking any opinion or belief, no
matter how deeply held, with open disrespect and the same unrelented
enthusiasm of a toddler who has just learned the word "poo".

Attachment: sender_key.asc
Description: application/pgp-keys

Reply via email to