diff options
author | Damien George <damien@micropython.org> | 2024-11-11 12:04:57 +1100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2024-11-13 13:35:37 +1100 |
commit | 611d8f9ce82ab5e04fb86ab6cfc28d5ed98f33bf (patch) | |
tree | 6f6b4820753c65ff14cde66d66bb63dee82a97fe | |
parent | 77406b4240b0489963782a7f18920ba3c5d11263 (diff) |
esp32/modsocket: Fix getaddrinfo hints to set AI_CANONNAME.
Because the `ai_canonname` field is subsequently used.
ESP32_GENERIC_S3 (at least) crashes with IDF 5.2.3 without this set.
Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r-- | ports/esp32/modsocket.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ports/esp32/modsocket.c b/ports/esp32/modsocket.c index 916eb79bd..7ea5e855d 100644 --- a/ports/esp32/modsocket.c +++ b/ports/esp32/modsocket.c @@ -213,7 +213,7 @@ static int mdns_getaddrinfo(const char *host_str, const char *port_str, #endif // MICROPY_HW_ENABLE_MDNS_QUERIES static void _getaddrinfo_inner(const mp_obj_t host, const mp_obj_t portx, - const struct addrinfo *hints, struct addrinfo **res) { + struct addrinfo *hints, struct addrinfo **res) { int retval = 0; *res = NULL; @@ -235,6 +235,9 @@ static void _getaddrinfo_inner(const mp_obj_t host, const mp_obj_t portx, MP_THREAD_GIL_EXIT(); + // The ai_canonname field is used below, so set the hint. + hints->ai_flags |= AI_CANONNAME; + #if MICROPY_HW_ENABLE_MDNS_QUERIES retval = mdns_getaddrinfo(host_str, port_str, hints, res); #endif @@ -264,7 +267,8 @@ static void _getaddrinfo_inner(const mp_obj_t host, const mp_obj_t portx, static void _socket_getaddrinfo(const mp_obj_t addrtuple, struct addrinfo **resp) { mp_obj_t *elem; mp_obj_get_array_fixed_n(addrtuple, 2, &elem); - _getaddrinfo_inner(elem[0], elem[1], NULL, resp); + struct addrinfo hints = { 0 }; + _getaddrinfo_inner(elem[0], elem[1], &hints, resp); } static mp_obj_t socket_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { |