<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hello,<br>
</p>
<p>The <span style="font-size:85%;"><span class="serif-fonts"
style="font-family: 'Georgia Pro', Georgia, 'DejaVu Serif', Times, 'Times New Roman', FreeSerif, 'DejaVu Math TeX', 'URW Bookman L', serif;">“</span></span>dateHeader()”
function in RTSPCommon.cpp obeys the current locale, while it
really shouldn't. As a result, Date: headers may be shown in
localized format, which is undesirable and probably not allowed by
the RTSP specification.</p>
<p>To reproduce:</p>
<p>Add <span style="font-size:85%;"><span class="serif-fonts"
style="font-family: 'Georgia Pro', Georgia, 'DejaVu Serif', Times, 'Times New Roman', FreeSerif, 'DejaVu Math TeX', 'URW Bookman L', serif;">“</span></span>#include
<locale.h>” and add <span style="font-size:85%;"><span
class="serif-fonts"
style="font-family: 'Georgia Pro', Georgia, 'DejaVu Serif', Times, 'Times New Roman', FreeSerif, 'DejaVu Math TeX', 'URW Bookman L', serif;">“</span></span>setlocale(LC_ALL,
"");” to the very beginning of <span style="font-size:85%;"><span
class="serif-fonts"
style="font-family: 'Georgia Pro', Georgia, 'DejaVu Serif', Times, 'Times New Roman', FreeSerif, 'DejaVu Math TeX', 'URW Bookman L', serif;">“</span></span>main()”
in live555MediaServer.cpp. Then run the server using a locale that
exists on the system, for example:</p>
<p>LC_ALL=fi_FI.UTF-8 ./live555MediaServer<br>
</p>
<p>Now, connecting to the server with telnet and entering some
invalid line results in the following reply:</p>
<p>RTSP/1.0 400 Bad Request<br>
Date: Ke, Hel 28 2024 09:56:24 GMT<br>
Allow: OPTIONS, DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE,
GET_PARAMETER, SET_PARAMETER<br>
</p>
<p>If using e.g. <span style="font-size:85%;"><span
class="serif-fonts"
style="font-family: 'Georgia Pro', Georgia, 'DejaVu Serif', Times, 'Times New Roman', FreeSerif, 'DejaVu Math TeX', 'URW Bookman L', serif;">“</span></span>ja_JP.UTF-8”,
the date is even more noticeably localized:<br>
</p>
<p>Date: 水, 2 28 2024 09:57:42 GMT<br>
<br>
</p>
<p>Proposed solution: Implement dateHeader() without using
strftime():<br>
</p>
<p>--- a/live/liveMedia/RTSPCommon.cpp<br>
+++ b/live/liveMedia/RTSPCommon.cpp<br>
@@ -365,7 +365,13 @@ char const* dateHeader() {<br>
time_tm = tm();<br>
}<br>
#endif<br>
- strftime(buf, sizeof buf, "Date: %a, %b %d %Y %H:%M:%S
GMT\r\n", &time_tm);<br>
+ static const char *day[] = { "Sun", "Mon", "Tue", "Wed", "Thu",
"Fri", "Sat" },<br>
+ *month[] = { "Jan", "Feb", "Mar", "Apr",
"May", "Jun",<br>
+ "Jul", "Aug", "Sep", "Oct",
"Nov", "Dec" };<br>
+ snprintf(buf, sizeof buf, "Date: %s, %s %02d %04d
%02d:%02d:%02d GMT\r\n",<br>
+ day[time_tm.tm_wday], month[time_tm.tm_mon],
time_tm.tm_mday,<br>
+ 1900 + time_tm.tm_year,<br>
+ time_tm.tm_hour, time_tm.tm_min, time_tm.tm_sec);<br>
#else<br>
// WinCE apparently doesn't have "time()", "strftime()", or
"gmtime()",<br>
// so generate the "Date:" header a different, WinCE-specific
way.<br>
<br>
</p>
<pre class="moz-signature" cols="72">--
(Mr) Lauri Nurmi
Software Engineer, M.Sc. (Tech.)
<a class="moz-txt-link-abbreviated" href="http://www.obseron.com">www.obseron.com</a></pre>
</body>
</html>