[PATCH] policycoreutils/run_init: handle NULL from crypt() in non-PAM build
Stephen Smalley <[email protected]>
| Newsgroups | org.kernel.vger.selinux |
|---|---|
| Message-ID | <[email protected]> |
crypt() returns NULL on error, so check for NULL and treat as if authentication failed in that case. Signed-off-by: Stephen Smalley <[email protected]> --- policycoreutils/run_init/run_init.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/policycoreutils/run_init/run_init.c b/policycoreutils/run_init/run_init.c index bb9593ad..89921b23 100644 --- a/policycoreutils/run_init/run_init.c +++ b/policycoreutils/run_init/run_init.c @@ -213,6 +213,8 @@ static int authenticate_via_shadow_passwd(const struct passwd *p_passwd_line) encrypted_password_s = crypt(unencrypted_password_s, p_shadow_line->sp_pwdp); memset(unencrypted_password_s, 0, strlen(unencrypted_password_s)); + if (!encrypted_password_s) + return 0; /* Return 1 (authenticated) iff the encrypted version of the user's * * input password matches the encrypted password stored in the * -- 2.55.0