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:
parent
740c619d33
commit
2c45774a35
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user