[git commit] httpd: do not try to use obviously bogus password from /etc/passwd
Denys Vlasenko
vda.linux at googlemail.com
Mon Oct 5 22:00:32 UTC 2026
commit: https://git.busybox.net/busybox/commit/?id=b829bba95095b87834628adb38ea14b5885c0fbc
branch: https://git.busybox.net/busybox/log/?h=master
If password is 'x' or '*' and yet, /etc/shadow has no entry,
do not run the crypt machinery - go to the next entry.
function old new delta
check_user_passwd 444 462 +18
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
networking/httpd.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/networking/httpd.c b/networking/httpd.c
index 7469de1de..a6daba044 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -2181,7 +2181,6 @@ static int check_user_passwd(const char *path, char *user_and_passwd)
# if ENABLE_FEATURE_SHADOWPASSWDS && !ENABLE_PAM
char sp_buf[256];
# endif
-
colon_after_user = strchr(user_and_passwd, ':');
if (!colon_after_user)
goto bad_input;
@@ -2236,8 +2235,9 @@ static int check_user_passwd(const char *path, char *user_and_passwd)
* At least glibc 2.4 does this. Be extra paranoid here. */
struct spwd *result = NULL;
r = getspnam_r(pw->pw_name, &spw, sp_buf, sizeof(sp_buf), &result);
- if (r == 0 && result)
- passwd = result->sp_pwdp;
+ if (r != 0 || !result)
+ continue; /* no shadow, and passwd entry is bogus one-char string */
+ passwd = result->sp_pwdp;
}
# endif
/* In this case, passwd is ALWAYS encrypted:
@@ -2250,9 +2250,7 @@ static int check_user_passwd(const char *path, char *user_and_passwd)
if (passwd[0] == '$' && (isdigit(passwd[1]) || passwd[1] == 'y')) {
char *encrypted;
-# if !ENABLE_PAM
- check_encrypted:
-# endif
+ IF_NOT_PAM(check_encrypted:)
/* encrypt pwd from peer and check match with local one */
encrypted = pw_encrypt(
/* pwd (from peer): */ colon_after_user + 1,
More information about the busybox-cvs
mailing list