diff --git a/libc/net/lib_gethostbynamer.c b/libc/net/lib_gethostbynamer.c index c1fe9ca8ea8..39dcec5c17c 100644 --- a/libc/net/lib_gethostbynamer.c +++ b/libc/net/lib_gethostbynamer.c @@ -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);