pkgsrc/security/sudo/patches/patch-lib_util_gethostname.c
maya ea36019c88 sudo: avoid segfault if hostname is empty
from andrew hall in pr pkg/52923
PKGREVISION++
2018-01-14 15:29:38 +00:00

16 lines
581 B
C

$NetBSD: patch-lib_util_gethostname.c,v 1.1 2018/01/14 15:29:38 maya Exp $
Avoid segfault if hostname is not set
(upstream commit)
--- lib/util/gethostname.c.orig 2017-01-14 04:30:15.000000000 +0000
+++ lib/util/gethostname.c
@@ -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 {