Skip to contentSkip to conversation

policycoreutils/run_init: handle NULL from crypt() in non-PAM build

PATCH In review Stephen Smalley 1 participant 2 messages Jul 16 – Jul 21 SELinux security module

lore
Share & tools
lore

Stephen Smalley

author maintainer
#0 lore raw

PATCH 1/1 policycoreutils/run_init: handle NULL from crypt() in non-PAM build

crypt() returns NULL on error, so check for NULL and treat as if authentication failed in that case.

---
 policycoreutils/run_init/run_init.c | 2 ++
 1 file changed, 2 insertions(+)
policycoreutils/run_init/run_init.c +2 -0
index bb9593ad..89921b23 100644
@@ -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      *
Signature · 1 line
2.55.0
author maintainer
#1 lore raw
Quoted 5 lines · Stephen Smalley

crypt() returns NULL on error, so check for NULL and treat as if authentication failed in that case.

Merged.

Quoted 20 lines
---
 policycoreutils/run_init/run_init.c | 2 ++
 1 file changed, 2 insertions(+)
policycoreutils/run_init/run_init.c +2 -1
index bb9593ad..89921b23 100644
@@ -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