From bf6f1b3d49e17b1adf0448c0b06e94b1e52ddffd Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Sat, 31 May 2014 19:06:56 +0200 Subject: Unify usage of function gethostname MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit man gethostanme says: NOTES SUSv2 guarantees that "Host names are limited to 255 bytes". POSIX.1-2001 guarantees that "Host names (not including the terminating null byte) are limited to HOST_NAME_MAX bytes". On Linux, HOST_NAME_MAX is defined with the value 64, which has been the limit since Linux 1.0 (earlier kernels imposed a limit of 8 bytes). Reviewed-by: Pavel Březina --- src/resolv/async_resolv_utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/resolv/async_resolv_utils.c') diff --git a/src/resolv/async_resolv_utils.c b/src/resolv/async_resolv_utils.c index b24ae603f..c5ae5f9d4 100644 --- a/src/resolv/async_resolv_utils.c +++ b/src/resolv/async_resolv_utils.c @@ -44,7 +44,7 @@ resolv_get_domain_send(TALLOC_CTX *mem_ctx, struct resolv_get_domain_state *state = NULL; struct tevent_req *req = NULL; struct tevent_req *subreq = NULL; - char system_hostname[HOST_NAME_MAX]; + char system_hostname[HOST_NAME_MAX + 1]; errno_t ret; req = tevent_req_create(mem_ctx, &state, @@ -63,7 +63,7 @@ resolv_get_domain_send(TALLOC_CTX *mem_ctx, ret, strerror(ret)); goto immediately; } - system_hostname[HOST_NAME_MAX-1] = '\0'; + system_hostname[HOST_NAME_MAX] = '\0'; hostname = system_hostname; } -- cgit