Subject: Re: gethostname and getdomainname
To: Ignatios Souvatzis <email@example.com>
From: Christos Zoulas <firstname.lastname@example.org>
Date: 11/13/1999 22:23:41
On Nov 13, 11:25pm, email@example.com (Ignatios Souvatzis) wrote:
-- Subject: Re: gethostname and getdomainname
| hm... If I like to use the code, with your suggestion, I as a game
| author (or game user who wants to fix the code) have to
| if (gethostname(buf, sizeof(buf) == -1)
| buf[sizeof(buf)-1] = '\0';
| This, or changing the application to provide a bigger buffer, is
| easy enough, if the user knows how to use an editor and compiler
| and has the sources.
| If he doesn't, his game prints to the score file: the score, his
| name, @, the start of the hostname, followed by binary gibberish,
| filling the terminal until the process gets a SEGV or the file
| system fills up.
| And this will only happen for users on a machine with a long name, like
| my-hostname-is-longer-than-yours (needing a 33 bytes buffer), while the
| stupid game author on jocelyn, also testing on beverly, specified only
| 32 bytes and never saw the problem.
| Would this really help?
I see your point, but the issue is that since gethostname is not guaranteed
to return a null terminated string, the code should be checking anyway.
We are developing a portable operating system, and it is a bit against
our philosophy to band-aid routines so that badly written code works.