mirror of https://github.com/ARMmbed/mbed-os.git
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
parent
24cebbaec3
commit
aafeef7401
|
|
@ -28,6 +28,10 @@ const char *NetworkStack::get_ip_address()
|
||||||
}
|
}
|
||||||
nsapi_error_t NetworkStack::gethostbyname(const char *name, SocketAddress *address, nsapi_version_t version)
|
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
|
// check for simple ip addresses
|
||||||
if (address->set_ip_address(name)) {
|
if (address->set_ip_address(name)) {
|
||||||
if (version != NSAPI_UNSPEC && address->get_ip_version() != version) {
|
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;
|
SocketAddress address;
|
||||||
|
|
||||||
|
if (name[0] == '\0') {
|
||||||
|
return NSAPI_ERROR_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
// check for simple ip addresses
|
// check for simple ip addresses
|
||||||
if (address.set_ip_address(name)) {
|
if (address.set_ip_address(name)) {
|
||||||
if (version != NSAPI_UNSPEC && address.get_ip_version() != version) {
|
if (version != NSAPI_UNSPEC && address.get_ip_version() != version) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue