esp32/modsocket: Fix crashes when connect/bind can't resolve given addr.
Fixes issue #4441.
This commit is contained in:
parent
1fa8f977f5
commit
dadee5fa24
@ -178,12 +178,16 @@ static int _socket_getaddrinfo2(const mp_obj_t host, const mp_obj_t portx, struc
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _socket_getaddrinfo(const mp_obj_t addrtuple, struct addrinfo **resp) {
|
STATIC void _socket_getaddrinfo(const mp_obj_t addrtuple, struct addrinfo **resp) {
|
||||||
mp_uint_t len = 0;
|
|
||||||
mp_obj_t *elem;
|
mp_obj_t *elem;
|
||||||
mp_obj_get_array(addrtuple, &len, &elem);
|
mp_obj_get_array_fixed_n(addrtuple, 2, &elem);
|
||||||
if (len != 2) return -1;
|
int res = _socket_getaddrinfo2(elem[0], elem[1], resp);
|
||||||
return _socket_getaddrinfo2(elem[0], elem[1], resp);
|
if (res != 0) {
|
||||||
|
mp_raise_OSError(res);
|
||||||
|
}
|
||||||
|
if (*resp == NULL) {
|
||||||
|
mp_raise_OSError(-2); // name or service not known
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC mp_obj_t socket_bind(const mp_obj_t arg0, const mp_obj_t arg1) {
|
STATIC mp_obj_t socket_bind(const mp_obj_t arg0, const mp_obj_t arg1) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user