From a0701bd8cb2ae882e844d4373b58c6b4ea6de0c6 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Wed, 28 May 2014 13:55:46 +0300 Subject: [PATCH] silcnet: handle OOM situation gracefully --- lib/silcutil/silcnet.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/silcutil/silcnet.c b/lib/silcutil/silcnet.c index 60a8a477..e2f7e239 100644 --- a/lib/silcutil/silcnet.c +++ b/lib/silcutil/silcnet.c @@ -447,8 +447,11 @@ SilcBool silc_net_check_host_by_sock(SilcSocket sock, char **hostname, if (!ip || !silc_net_gethostbyaddr(*ip, host, sizeof(host))) return FALSE; + SILC_LOG_DEBUG(("Resolved hostname `%s'", host)); + *hostname = silc_memdup(host, strlen(host)); - SILC_LOG_DEBUG(("Resolved hostname `%s'", *hostname)); + if (!(*hostname)) + return FALSE; /* Reverse */ if (!silc_net_gethostbyname(*hostname, TRUE, host, sizeof(host))) @@ -533,8 +536,11 @@ SilcBool silc_net_check_local_by_sock(SilcSocket sock, char **hostname, if (!ip || !silc_net_gethostbyaddr(*ip, host, sizeof(host))) return FALSE; + SILC_LOG_DEBUG(("Resolved hostname `%s'", host)); + *hostname = silc_memdup(host, strlen(host)); - SILC_LOG_DEBUG(("Resolved hostname `%s'", *hostname)); + if (!(*hostname)) + return FALSE; /* Reverse */ if (!silc_net_gethostbyname(*hostname, TRUE, host, sizeof(host))) -- 2.24.0