Attached is a patch for live555 to avoid usage of `gmtime`, which is not
guaranteed to return a pointer to data in thread-local storage, so could
race with other threads. Unfortunately, there is no cross-platform
replacement, so this adds an ifdef to call the corresponding threadsafe
alternatives.

Thank you for considering the patch!

Russell Greene
SHOTOVER Systems

-- 

diff --git a/liveMedia/RTSPCommon.cpp b/liveMedia/RTSPCommon.cpp
index bab17f9..47efe95 100644
--- a/liveMedia/RTSPCommon.cpp
+++ b/liveMedia/RTSPCommon.cpp
@@ -355,7 +355,17 @@ char const* dateHeader() {
   static char buf[200];
 #if !defined(_WIN32_WCE)
   time_t tt = time(NULL);
-  strftime(buf, sizeof buf, "Date: %a, %b %d %Y %H:%M:%S GMT\r\n", gmtime(&tt));
+  tm time_tm;
+#ifdef _WIN32
+  if (gmtime_s(&time_tm, &tt) != 0) {
+      time_tm = tm{};
+  }
+#else
+  if (gmtime_r(&tt, &time_tm) == nullptr) {
+      time_tm = tm{};
+  }
+#endif
+  strftime(buf, sizeof buf, "Date: %a, %b %d %Y %H:%M:%S GMT\r\n", &time_tm);
 #else
   // WinCE apparently doesn't have "time()", "strftime()", or "gmtime()",
   // so generate the "Date:" header a different, WinCE-specific way.
_______________________________________________
live-devel mailing list
live-devel@lists.live555.com
http://lists.live555.com/mailman/listinfo/live-devel

Reply via email to