Ensure that host name is always null-terminated.

This commit is contained in:
W. Eric Norum
2001-07-13 18:48:03 +00:00
parent 24a08c9c78
commit 9803b24aa9

View File

@@ -26,13 +26,13 @@ localHostName::localHostName ()
status = gethostname ( this->cache, sizeof ( this->cache ) );
if ( status ) {
strncpy ( this->cache, "<unknown host>", sizeof ( this->cache ) );
this->cache [ sizeof ( this->cache ) - 1u ] = '\0';
}
}
else {
this->attachedToSockLib = false;
strncpy ( this->cache, "<unknown host>", sizeof ( this->cache ) );
}
this->cache [ sizeof ( this->cache ) - 1u ] = '\0';
this->length = strlen ( this->cache );
}