From: Alejandro Colomar Date: Fri, 1 Sep 2023 23:49:00 +0000 (+0200) Subject: lib/pwauth.c: Simplify empty string X-Git-Tag: 4.15.0-rc1~181 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=158866bfdcaa9aea4a8e355975b9aa9200c69fce;p=thirdparty%2Fshadow.git lib/pwauth.c: Simplify empty string And do not set 'clear' to point to the empty string. After this commit, 'clear' only stores the result of getpass(3). This will be useful to change the code to use agetpass(). $ grep '\' lib/pwauth.c; char *clear = NULL; clear = getpass (prompt); input = (clear == NULL) ? "" : clear; clear = getpass (prompt); input = (clear == NULL) ? "" : clear; if (NULL != clear) { strzero (clear); Signed-off-by: Alejandro Colomar --- diff --git a/lib/pwauth.c b/lib/pwauth.c index c6bb1f49e..965cb1412 100644 --- a/lib/pwauth.c +++ b/lib/pwauth.c @@ -138,13 +138,7 @@ int pw_auth (const char *cipher, snprintf (prompt, sizeof prompt, cp, user); clear = getpass (prompt); - if (NULL == clear) { - static char c[1]; - - c[0] = '\0'; - clear = c; - } - input = clear; + input = (clear == NULL) ? "" : clear; } /* @@ -171,13 +165,7 @@ int pw_auth (const char *cipher, */ if ((0 != retval) && ('\0' == input[0]) && use_skey) { clear = getpass (prompt); - if (NULL == clear) { - static char c[1]; - - c[0] = '\0'; - clear = c; - } - input = clear; + input = (clear == NULL) ? "" : clear; } if ((0 != retval) && use_skey) {