From 6e20775978a8a4f9c202586de172c9d355526d33 Mon Sep 17 00:00:00 2001 From: EunBong Song Date: Fri, 14 Jul 2017 06:20:23 -0700 Subject: [PATCH] libc: netdb: Fix bugs in lib_gethostbynamer.c This fix sets h_name in struct hostent returned by gethostbyname() This patch comes from Nuttx community. Commit id: 6ccc01ad Change-Id: I8a92e862081e62ec2fa09c378eb86bb7c5736182 Signed-off-by: EunBong Song --- lib/libc/netdb/lib_gethostbynamer.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/libc/netdb/lib_gethostbynamer.c b/lib/libc/netdb/lib_gethostbynamer.c index 3928b7d..57db394 100644 --- a/lib/libc/netdb/lib_gethostbynamer.c +++ b/lib/libc/netdb/lib_gethostbynamer.c @@ -220,6 +220,11 @@ static int lib_numeric_address(FAR const char *name, FAR struct hostent *host, F } strncpy(ptr, name, buflen); + + /* Set the address to h_name */ + + host->h_name = ptr; + return 0; } @@ -300,6 +305,10 @@ static int lib_localhost(FAR const char *name, FAR struct hostent *host, FAR cha } strncpy(dest, name, buflen); + + /* Set the address to h_name */ + + host->h_name = dest; return 0; } @@ -408,6 +417,10 @@ static int lib_find_answer(FAR const char *name, FAR struct hostent *host, FAR c } strncpy(ptr, name, buflen); + + /* Set the address to h_name */ + + host->h_name = ptr; return OK; } #endif /* CONFIG_NETDB_DNSCLIENT */ @@ -544,6 +557,10 @@ static int lib_dns_lookup(FAR const char *name, FAR struct hostent *host, FAR ch } strncpy(ptr, name, buflen); + + /* Set the address to h_name */ + + host->h_name = ptr; return OK; } -- 2.7.4