Skip to content

Commit 611d8f9

Browse files
committed
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 <[email protected]>
1 parent 77406b4 commit 611d8f9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

ports/esp32/modsocket.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ static int mdns_getaddrinfo(const char *host_str, const char *port_str,
213213
#endif // MICROPY_HW_ENABLE_MDNS_QUERIES
214214

215215
static void _getaddrinfo_inner(const mp_obj_t host, const mp_obj_t portx,
216-
const struct addrinfo *hints, struct addrinfo **res) {
216+
struct addrinfo *hints, struct addrinfo **res) {
217217
int retval = 0;
218218

219219
*res = NULL;
@@ -235,6 +235,9 @@ static void _getaddrinfo_inner(const mp_obj_t host, const mp_obj_t portx,
235235

236236
MP_THREAD_GIL_EXIT();
237237

238+
// The ai_canonname field is used below, so set the hint.
239+
hints->ai_flags |= AI_CANONNAME;
240+
238241
#if MICROPY_HW_ENABLE_MDNS_QUERIES
239242
retval = mdns_getaddrinfo(host_str, port_str, hints, res);
240243
#endif
@@ -264,7 +267,8 @@ static void _getaddrinfo_inner(const mp_obj_t host, const mp_obj_t portx,
264267
static void _socket_getaddrinfo(const mp_obj_t addrtuple, struct addrinfo **resp) {
265268
mp_obj_t *elem;
266269
mp_obj_get_array_fixed_n(addrtuple, 2, &elem);
267-
_getaddrinfo_inner(elem[0], elem[1], NULL, resp);
270+
struct addrinfo hints = { 0 };
271+
_getaddrinfo_inner(elem[0], elem[1], &hints, resp);
268272
}
269273

270274
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) {

0 commit comments

Comments
 (0)