Use returned network name from getnetbyaddr() correctly.

This commit is contained in:
ume 2015-11-05 11:02:28 +00:00
parent 4908bcb50a
commit e649998b7f

View File

@ -637,14 +637,13 @@ netname4(in_addr_t in, in_addr_t mask)
trimdomain(cp, strlen(cp));
}
}
inet_ntop(AF_INET, &in, nline, sizeof(line));
if (cp != NULL) {
if (strcpy(cp, nline) != 0)
return (line);
if (cp != NULL)
strlcpy(line, cp, sizeof(line));
} else
else {
inet_ntop(AF_INET, &in, nline, sizeof(nline));
strlcpy(line, nline, sizeof(line));
domask(line + strlen(line), i, ntohl(mask));
domask(line + strlen(line), i, ntohl(mask));
}
return (line);
}