2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-30 05:48:18 +00:00

Treat an empty hostname as a failure and return NULL.

This commit is contained in:
Todd C. Miller 2017-10-20 07:37:40 -06:00
parent 740c619d33
commit 2c45774a35

View File

@ -42,7 +42,7 @@ sudo_gethostname_v1(void)
hname = malloc(host_name_max + 1);
if (hname != NULL) {
if (gethostname(hname, host_name_max + 1) == 0) {
if (gethostname(hname, host_name_max + 1) == 0 && *hname != '\0') {
/* Old gethostname() may not NUL-terminate if there is no room. */
hname[host_name_max] = '\0';
} else {