From 2968f0e881d5aa6eb1b620e8b69257cfa8ec66ba Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Thu, 2 Oct 2025 08:31:19 -0700 Subject: [PATCH] Use gmtime_r for multicore safety in HTTPClient --- libraries/HTTPClient/src/HTTPClient.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/HTTPClient/src/HTTPClient.cpp b/libraries/HTTPClient/src/HTTPClient.cpp index 0e2f8fcf3..b548c557a 100644 --- a/libraries/HTTPClient/src/HTTPClient.cpp +++ b/libraries/HTTPClient/src/HTTPClient.cpp @@ -1323,7 +1323,8 @@ void HTTPClient::setCookie(String date, String headerValue) { // overwrite or delete cookie in/from cookie jar time_t now_local = time(NULL); - time_t now_gmt = mktime(gmtime(&now_local)); + struct tm timeinfo; + time_t now_gmt = mktime(gmtime_r(&now_local, &timeinfo)); bool found = false; @@ -1353,7 +1354,8 @@ bool HTTPClient::generateCookieString(String *cookieString) { return false; } time_t now_local = time(NULL); - time_t now_gmt = mktime(gmtime(&now_local)); + struct tm timeinfo; + time_t now_gmt = mktime(gmtime_r(&now_local, &timeinfo)); *cookieString = ""; bool found = false;