netdb: Fix bugs in lib_gethostbynamer.c

This fix sets h_name in struct hostent returned by gethostbyname()

Signed-off-by: Masayuki Ishikawa <masayuki.ishikawa@gmail.com>
This commit is contained in:
Masayuki Ishikawa 2017-05-25 09:22:34 +09:00
parent c31dbf244e
commit 6ccc01ad46

View File

@ -205,6 +205,10 @@ static int lib_numeric_address(FAR const char *name, FAR struct hostent *host,
}
strncpy(ptr, name, buflen);
/* Set the address to h_name */
host->h_name = ptr;
return 0;
}
@ -289,6 +293,10 @@ static int lib_localhost(FAR const char *name, FAR struct hostent *host,
}
strncpy(dest, name, buflen);
/* Set the address to h_name */
host->h_name = dest;
return 0;
}
@ -401,6 +409,10 @@ static int lib_find_answer(FAR const char *name, FAR struct hostent *host,
}
strncpy(ptr, name, buflen);
/* Set the address to h_name */
host->h_name = ptr;
return OK;
}
#endif /* CONFIG_NETDB_DNSCLIENT */
@ -543,6 +555,10 @@ static int lib_dns_lookup(FAR const char *name, FAR struct hostent *host,
}
strncpy(ptr, name, buflen);
/* Set the address to h_name */
host->h_name = ptr;
return OK;
}