gethostbyname won't accept empty name

Considers both versions - synchronous and asynchronous. Earlier the
underlying stack was trusted to do this check.
pull/7054/head
Veijo Pesonen 2018-05-30 12:01:24 +03:00
parent 24cebbaec3
commit aafeef7401
1 changed files with 8 additions and 0 deletions

View File

@ -28,6 +28,10 @@ const char *NetworkStack::get_ip_address()
}
nsapi_error_t NetworkStack::gethostbyname(const char *name, SocketAddress *address, nsapi_version_t version)
{
if (name[0] == '\0') {
return NSAPI_ERROR_PARAMETER;
}
// check for simple ip addresses
if (address->set_ip_address(name)) {
if (version != NSAPI_UNSPEC && address->get_ip_version() != version) {
@ -53,6 +57,10 @@ nsapi_value_or_error_t NetworkStack::gethostbyname_async(const char *name, hostb
{
SocketAddress address;
if (name[0] == '\0') {
return NSAPI_ERROR_PARAMETER;
}
// check for simple ip addresses
if (address.set_ip_address(name)) {
if (version != NSAPI_UNSPEC && address.get_ip_version() != version) {