* src/login.c: utent might be NULL after get_current_utmp().

This commit is contained in:
nekral-guest 2009-04-22 20:07:34 +00:00
parent 332a50c273
commit a362a68f53
2 changed files with 9 additions and 7 deletions

View File

@ -1,3 +1,7 @@
2009-04-22 Paul Szabo <psz@maths.usyd.edu.au>
* src/login.c: utent might be NULL after get_current_utmp().
2009-04-22 Nicolas François <nicolas.francois@centraliens.net> 2009-04-22 Nicolas François <nicolas.francois@centraliens.net>
* src/login.c: Removed temp_shell. No more used. * src/login.c: Removed temp_shell. No more used.

View File

@ -563,6 +563,7 @@ int main (int argc, char **argv)
(void) puts (_("No utmp entry. You must exec \"login\" from the lowest level \"sh\"")); (void) puts (_("No utmp entry. You must exec \"login\" from the lowest level \"sh\""));
exit (1); exit (1);
} }
/* NOTE: utent might be NULL afterwards */
tmptty = ttyname (0); tmptty = ttyname (0);
if (NULL == tmptty) { if (NULL == tmptty) {
@ -655,16 +656,13 @@ int main (int argc, char **argv)
if (rflg || hflg) { if (rflg || hflg) {
cp = hostname; cp = hostname;
} else {
#ifdef HAVE_STRUCT_UTMP_UT_HOST #ifdef HAVE_STRUCT_UTMP_UT_HOST
if ('\0' != utent->ut_host[0]) { } else if ((NULL != utent) && ('\0' != utent->ut_host[0])) {
cp = utent->ut_host; cp = utent->ut_host;
} else
#endif /* HAVE_STRUCT_UTMP_UT_HOST */ #endif /* HAVE_STRUCT_UTMP_UT_HOST */
{ } else {
cp = ""; cp = "";
} }
}
if ('\0' != *cp) { if ('\0' != *cp) {
snprintf (fromhost, sizeof fromhost, snprintf (fromhost, sizeof fromhost,