- if (LONE_CHAR(pw->pw_passwd, 'x') || LONE_CHAR(pw->pw_passwd, '*')) {
- if (getspnam_r(pw->pw_name, &spw, buffer, sizeof(buffer), &result))
- bb_error_msg("no valid shadow password, checking ordinary one");
- else
- correct = spw.sp_pwdp;
+ if ((correct[0] == 'x' || correct[0] == '*') && !correct[1]) {
+ /* 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;
+ r = getspnam_r(pw->pw_name, &spw, buffer, sizeof(buffer), &result);
+ correct = (r || !result) ? "aa" : result->sp_pwdp;