From: Tobias Stoeckmann Date: Fri, 9 Jan 2026 16:28:53 +0000 (+0100) Subject: su: Drop unneeded char buffers X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2852d7aeedf05b8f8611ac47aed40a8562ed6107;p=thirdparty%2Fshadow.git su: Drop unneeded char buffers Since kill_child is no signal handler any longer, it is safe to call the gettext macros directly and only when needed. Reviewed-by: Alejandro Colomar Reviewed-by: Ruihan Li Signed-off-by: Tobias Stoeckmann --- diff --git a/src/su.c b/src/su.c index 9f32733ee..6268f50fa 100644 --- a/src/su.c +++ b/src/su.c @@ -60,7 +60,6 @@ #include "prototypes.h" #include "shadowlog.h" #include "string/sprintf/aprintf.h" -#include "string/sprintf/snprintf.h" #include "string/strcmp/streq.h" #include "string/strcmp/strprefix.h" #include "string/strcpy/strtcpy.h" @@ -94,8 +93,6 @@ static char caller_name[BUFSIZ]; static bool change_environment = true; #ifdef USE_PAM -static char kill_msg[256]; -static char wait_msg[256]; static pam_handle_t *pamh = NULL; static volatile sig_atomic_t caught = 0; static volatile sig_atomic_t timeout = 0; @@ -176,9 +173,9 @@ kill_child(int) { if (0 != pid_child) { (void) kill (-pid_child, SIGKILL); - (void) write_full(STDERR_FILENO, kill_msg, strlen(kill_msg)); + fputs(_(" ...killed.\n"), stderr); } else { - (void) write_full(STDERR_FILENO, wait_msg, strlen(wait_msg)); + fputs(_(" ...waiting for child to terminate.\n"), stderr); } _exit (255); } @@ -403,9 +400,6 @@ static void prepare_pam_close_session (void) stderr); (void) kill (-pid_child, caught); - stprintf_a(kill_msg, _(" ...killed.\n")); - stprintf_a(wait_msg, _(" ...waiting for child to terminate.\n")); - /* Any signals other than SIGCHLD and SIGALRM will no longer have any effect, * so it's time to block all of them. */ sigfillset (&ourset);