diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c index 62d65fabc721..ac5b73266067 100644 --- a/sys/kern/kern_jail.c +++ b/sys/kern/kern_jail.c @@ -241,10 +241,19 @@ jailed(cred) /* * Return the correct hostname for the passed credential. */ -const char * -getcredhostname(cred) +void +getcredhostname(cred, buf, size) struct ucred *cred; + char *buf; + size_t size; { - return (jailed(cred) ? cred->cr_prison->pr_host : hostname); + if (jailed(cred)) { + mtx_lock(&cred->cr_prison->pr_mtx); + strncpy(buf, cred->cr_prison->pr_host, size); + mtx_unlock(&cred->cr_prison->pr_mtx); + } + else + strncpy(buf, hostname, size); + buf[size - 1] = '\0'; } diff --git a/sys/sys/jail.h b/sys/sys/jail.h index f9f7b814c133..1fef842a5f7d 100644 --- a/sys/sys/jail.h +++ b/sys/sys/jail.h @@ -68,7 +68,7 @@ extern int jail_sysvipc_allowed; struct ucred; struct sockaddr; int jailed __P((struct ucred *cred)); -const char *getcredhostname __P((struct ucred *cred)); +void getcredhostname __P((struct ucred *cred, char *, size_t)); int prison_check __P((struct ucred *cred1, struct ucred *cred2)); void prison_free __P((struct prison *pr)); u_int32_t prison_getip __P((struct ucred *cred));