Skip to content

Commit 2793282

Browse files
Use gmtime_r for multicore safety in HTTPClient (#3170)
1 parent 6aad689 commit 2793282

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

libraries/HTTPClient/src/HTTPClient.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,8 @@ void HTTPClient::setCookie(String date, String headerValue) {
13231323

13241324
// overwrite or delete cookie in/from cookie jar
13251325
time_t now_local = time(NULL);
1326-
time_t now_gmt = mktime(gmtime(&now_local));
1326+
struct tm timeinfo;
1327+
time_t now_gmt = mktime(gmtime_r(&now_local, &timeinfo));
13271328

13281329
bool found = false;
13291330

@@ -1353,7 +1354,8 @@ bool HTTPClient::generateCookieString(String *cookieString) {
13531354
return false;
13541355
}
13551356
time_t now_local = time(NULL);
1356-
time_t now_gmt = mktime(gmtime(&now_local));
1357+
struct tm timeinfo;
1358+
time_t now_gmt = mktime(gmtime_r(&now_local, &timeinfo));
13571359

13581360
*cookieString = "";
13591361
bool found = false;

0 commit comments

Comments
 (0)