]> granicus.if.org Git - sudo/commitdiff
Treat an empty hostname as a failure and return NULL.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 20 Oct 2017 13:37:40 +0000 (07:37 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 20 Oct 2017 13:37:40 +0000 (07:37 -0600)
lib/util/gethostname.c

index 7f24458d6f6433936dbd2941485d0ac72c761b58..a10243f39a652d82e53e2635452b4b6c02130f3f 100644 (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 {