🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.bugs.v7
Article #43

getlogin bug

#43
From: utzoohenry
Date: Thu, 25 Feb 1982 23:37
15 lines
883 bytes
The getlogin() routine supplied with V7 has a serious bug, a result
of an apparent misunderstanding.  The utmp(5) manual page never gets
around to giving a precise definition of what a utmp entry looks like
if there is no user on that line.  In practice, what init does is to
write NULs on the user name.  But the standard getlogin does not check
for this!  The result is a null-string (rather than NULL) return from
getlogin.  The fix is quite straightforward;  add the following after
"close(uf);":

	if (ubuf.ut_name[0] == '\0')
		return(0);

While you're at it, you might want to add a "close(uf);" to the error
return that immediately precedes this code:  it carelessly leaves the
file descriptor open.
Technical Details
Message-ID: <anews.Autzoo.1437>
Path: arc1-ca.pugleaf.net!utzoo!henry

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!henry
From: utzoo!henry
Newsgroups: net.bugs.v7
Subject: getlogin bug
Date: Thu, 25 Feb 1982 23:37:58 +0000
Message-ID: <anews.Autzoo.1437>