summaryrefslogtreecommitdiff
path: root/loginutils/sulogin.c
diff options
context:
space:
mode:
authorDenis Vlasenko2007-10-29 19:25:45 +0000
committerDenis Vlasenko2007-10-29 19:25:45 +0000
commit15ca51e3e2a31efc275b616106244d8ec3f8f773 (patch)
treee54716fcb612a54cfa72564d9ef089eebe92acbd /loginutils/sulogin.c
parent5a28a25b9dd81e0975532458723c4244ff532e58 (diff)
downloadbusybox-15ca51e3e2a31efc275b616106244d8ec3f8f773.zip
busybox-15ca51e3e2a31efc275b616106244d8ec3f8f773.tar.gz
appletlib.c: make it actally follow _BB_SUID_ALWAYS rules
adduser: implement -S and code shrink / fix uid selection *: sanitize getspnam_r use text data bss dec hex filename 777042 974 9676 787692 c04ec busybox_old 776883 974 9676 787533 c044d busybox_unstripped
Diffstat (limited to 'loginutils/sulogin.c')
-rw-r--r--loginutils/sulogin.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/loginutils/sulogin.c b/loginutils/sulogin.c
index f633fbb..f1545b7 100644
--- a/loginutils/sulogin.c
+++ b/loginutils/sulogin.c
@@ -44,7 +44,6 @@ int sulogin_main(int argc, char **argv)
/* Using _r function to avoid pulling in static buffers */
char buffer[256];
struct spwd spw;
- struct spwd *result;
#endif
logmode = LOGMODE_BOTH;
@@ -83,10 +82,16 @@ int sulogin_main(int argc, char **argv)
}
#if ENABLE_FEATURE_SHADOWPASSWDS
- if (getspnam_r(pwd->pw_name, &spw, buffer, sizeof(buffer), &result)) {
- goto auth_error;
+ {
+ /* getspnam_r may return 0 yet set result to NULL.
+ * At least glibc 2.4 does this. Be extra paranoid here. */
+ struct spwd *result = NULL;
+ int r = getspnam_r(pwd->pw_name, &spw, buffer, sizeof(buffer), &result);
+ if (r || !result) {
+ goto auth_error;
+ }
+ pwd->pw_passwd = result->sp_pwdp;
}
- pwd->pw_passwd = spw.sp_pwdp;
#endif
while (1) {