gethostbyname() should succeed for matches on host name aliases as well

This commit is contained in:
Gregory Nutt 2015-07-09 09:14:42 -06:00
parent 3971d97332
commit 2be9bfa40a
1 changed files with 23 additions and 0 deletions

View File

@ -301,6 +301,9 @@ int gethostbyname_r(FAR const char *name, FAR struct hostent *host,
/* We successfully read the entry */
nvdbg("Comparing %s to %s\n", name, host->h_name);
/* Check for a host name match */
if (strcmp(name, host->h_name) == 0)
{
/* We have a match */
@ -308,6 +311,26 @@ int gethostbyname_r(FAR const char *name, FAR struct hostent *host,
fclose(stream);
return OK;
}
/* For a match with any host alias */
if (host->h_aliases != NULL)
{
FAR char **alias;
for (alias = host->h_aliases; *alias != NULL; alias++)
{
/* Check for a host alias match */
if (strcmp(name, *alias) == 0)
{
/* We have a match */
fclose(stream);
return OK;
}
}
}
}
}
while (nread != 0);