From 1641a7c0026c49816cc0f671227c68e004dc0d9d Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 12 Oct 2022 11:36:34 -0500 Subject: [PATCH] Pico W: ssl: Correctly handle errors in send/recv The prefixed versions raise Python exceptions, the un-prefixed return negative error values. We don't want to raise an exception from here, it leaves the SSL stack in an undefined state. --- ports/raspberrypi/common-hal/ssl/SSLSocket.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/raspberrypi/common-hal/ssl/SSLSocket.c b/ports/raspberrypi/common-hal/ssl/SSLSocket.c index 8712fbb378..ba91e084cd 100644 --- a/ports/raspberrypi/common-hal/ssl/SSLSocket.c +++ b/ports/raspberrypi/common-hal/ssl/SSLSocket.c @@ -100,7 +100,7 @@ STATIC int _mbedtls_ssl_send(void *ctx, const byte *buf, size_t len) { mp_obj_t sock = *(mp_obj_t *)ctx; // mp_uint_t out_sz = sock_stream->write(sock, buf, len, &err); - mp_int_t out_sz = common_hal_socketpool_socket_send(sock, buf, len); + mp_int_t out_sz = socketpool_socket_send(sock, buf, len); DEBUG("socket_send() -> %d", out_sz); if (out_sz < 0) { int err = -out_sz; @@ -118,7 +118,7 @@ STATIC int _mbedtls_ssl_send(void *ctx, const byte *buf, size_t len) { STATIC int _mbedtls_ssl_recv(void *ctx, byte *buf, size_t len) { mp_obj_t sock = *(mp_obj_t *)ctx; - mp_int_t out_sz = common_hal_socketpool_socket_recv_into(sock, buf, len); + mp_int_t out_sz = socketpool_socket_recv_into(sock, buf, len); DEBUG("socket_recv() -> %d", out_sz); if (out_sz < 0) { int err = -out_sz;