Use MAXHOSTNAMELEN+1 when allocating host/domain name since some
systems do not include space for the NUL in the size. Also manually NUL-terminate buffer from gethostname() since POSIX is wishy-washy on this.
This commit is contained in:
4
match.c
4
match.c
@@ -793,8 +793,8 @@ netgr_matches(netgr, lhost, shost, user)
|
||||
#ifdef HAVE_GETDOMAINNAME
|
||||
/* get the domain name (if any) */
|
||||
if (!initialized) {
|
||||
domain = (char *) emalloc(MAXHOSTNAMELEN);
|
||||
if (getdomainname(domain, MAXHOSTNAMELEN) == -1 || *domain == '\0') {
|
||||
domain = (char *) emalloc(MAXHOSTNAMELEN + 1);
|
||||
if (getdomainname(domain, MAXHOSTNAMELEN + 1) == -1 || *domain == '\0') {
|
||||
efree(domain);
|
||||
domain = NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user