Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
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 f633fbbf1..f1545b78f 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) {