frame_serialize: use reentrant gmtime in CBOR date decoding

gmtime() returns a pointer to a shared static buffer, so concurrent
deserialization of CborUnixTime_tTag values was a data race. Decode into a local
struct tm via gmtime_r (gmtime_s on Windows) instead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-18 14:25:30 +02:00
co-authored by Claude Opus 4.8
parent 086129f767
commit 52f349b9f1
+7 -1
View File
@@ -85,8 +85,14 @@ namespace {
return GetCBORString(value);
else if (tag == CborUnixTime_tTag) {
time_t t = GetCBORUInt(value);
struct tm tm_buf{};
#ifdef _WIN32
gmtime_s(&tm_buf, &t);
#else
gmtime_r(&t, &tm_buf);
#endif
char buf1[255];
strftime(buf1, sizeof(buf1), "%FT%T", gmtime(&t));
strftime(buf1, sizeof(buf1), "%FT%T", &tm_buf);
return std::string(buf1) + "Z";
} else
throw JFJochException(JFJochExceptionCategory::CBORError, "Time/date tag error");