From 258ee1886f4a2005e9a6d0c810c7e40e49e6d089 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Wed, 19 Aug 2020 07:19:48 +0100 Subject: [PATCH] coverity: 37468: confirm gethostname worked --- lib/roles/http/server/server.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/roles/http/server/server.c b/lib/roles/http/server/server.c index 38e03c8d0..2e6d09b69 100644 --- a/lib/roles/http/server/server.c +++ b/lib/roles/http/server/server.c @@ -3071,8 +3071,10 @@ lws_server_get_canonical_hostname(struct lws_context *context, return; #if !defined(LWS_PLAT_FREERTOS) /* find canonical hostname */ - gethostname((char *)context->canonical_hostname, - sizeof(context->canonical_hostname) - 1); + if (gethostname((char *)context->canonical_hostname, + sizeof(context->canonical_hostname) - 1)) + lws_strncpy((char *)context->canonical_hostname, "unknown", + sizeof(context->canonical_hostname)); lwsl_info(" canonical_hostname = %s\n", context->canonical_hostname); #else