X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/0a7de7458d150b5d4dffc935ba399be265ef0a1a..c6bf4f310a33a9262d455ea4d3f0630b1255e3fe:/bsd/kern/bsd_stubs.c diff --git a/bsd/kern/bsd_stubs.c b/bsd/kern/bsd_stubs.c index fb33955de..f73834598 100644 --- a/bsd/kern/bsd_stubs.c +++ b/bsd/kern/bsd_stubs.c @@ -348,16 +348,21 @@ cdevsw_setkqueueok(int maj, struct cdevsw * csw, int extra_flags) int bsd_hostname(char * buf, int bufsize, int * len) { + int ret, hnlen; /* - * "hostname" is null-terminated, and "hostnamelen" is equivalent to strlen(hostname). + * "hostname" is null-terminated */ - if (hostnamelen < bufsize) { + lck_mtx_lock(&hostname_lock); + hnlen = strlen(hostname); + if (hnlen < bufsize) { strlcpy(buf, hostname, bufsize); - *len = hostnamelen; - return 0; + *len = hnlen; + ret = 0; } else { - return ENAMETOOLONG; + ret = ENAMETOOLONG; } + lck_mtx_unlock(&hostname_lock); + return ret; } void