Mercurial > hg > mlmmj
changeset 100:b08023b8393b
small fix for over-sized hostnames in hostnamestr()
author | mortenp |
---|---|
date | Sat, 22 May 2004 20:47:18 +1000 |
parents | 6089f38bb228 |
children | a19c8b8a8748 |
files | src/strgen.c |
diffstat | 1 files changed, 3 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/strgen.c Fri May 21 18:46:00 2004 +1000 +++ b/src/strgen.c Sat May 22 20:47:18 2004 +1000 @@ -120,7 +120,10 @@ struct hostent *hostlookup; char hostname[1024]; + /* TODO use dynamic allocation */ gethostname(hostname, sizeof(hostname) - 1); + /* gethostname() is allowed to return an unterminated string */ + hostname[sizeof(hostname)-1] = '\0'; hostlookup = gethostbyname(hostname); return strdup(hostlookup->h_name);