From 23e6b47a287019788382f1bb11c00033c1175ad0 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 10 Dec 2019 15:28:21 +0100 Subject: [PATCH] esp-tls: check return value of fcntl --- components/esp-tls/esp_tls.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/esp-tls/esp_tls.c b/components/esp-tls/esp_tls.c index 65cd789f39..b3a6ae3ecd 100644 --- a/components/esp-tls/esp_tls.c +++ b/components/esp-tls/esp_tls.c @@ -134,7 +134,11 @@ static esp_err_t esp_tcp_connect(const char *host, int hostlen, int port, int *s } if (cfg->non_block) { int flags = fcntl(fd, F_GETFL, 0); - fcntl(fd, F_SETFL, flags | O_NONBLOCK); + ret = fcntl(fd, F_SETFL, flags | O_NONBLOCK); + if (ret < 0) { + ESP_LOGE(TAG, "Failed to configure the socket as non-blocking (errno %d)", errno); + goto err_freesocket; + } } }