home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Bug_Fixes / Net.v7bugs / 0085 < prev    next >
Encoding:
Text File  |  1982-02-26  |  790 b   |  21 lines

  1. Autzoo.1437
  2. net.bugs.v7
  3. utcsrgv!utzoo!henry
  4. Thu Feb 25 23:37:58 1982
  5. getlogin bug
  6. The getlogin() routine supplied with V7 has a serious bug, a result
  7. of an apparent misunderstanding.  The utmp(5) manual page never gets
  8. around to giving a precise definition of what a utmp entry looks like
  9. if there is no user on that line.  In practice, what init does is to
  10. write NULs on the user name.  But the standard getlogin does not check
  11. for this!  The result is a null-string (rather than NULL) return from
  12. getlogin.  The fix is quite straightforward;  add the following after
  13. "close(uf);":
  14.  
  15.     if (ubuf.ut_name[0] == '\0')
  16.         return(0);
  17.  
  18. While you're at it, you might want to add a "close(uf);" to the error
  19. return that immediately precedes this code:  it carelessly leaves the
  20. file descriptor open.
  21.