]> git.sesse.net Git - vlc/blob - extras/contrib/src/Patches/live.patch
Fix hang in live555 when sending RTSP OPTIONS by letting readSocket() timeout after...
[vlc] / extras / contrib / src / Patches / live.patch
1 diff -ru live/groupsock/Groupsock.cpp live-patched/groupsock/Groupsock.cpp
2 --- live/groupsock/Groupsock.cpp        Thu Nov  6 03:53:15 2003
3 +++ live-patched/groupsock/Groupsock.cpp        Sun Dec  7 21:30:15 2003
4 @@ -26,7 +26,7 @@
5  #if defined(__WIN32__) || defined(_WIN32)
6  #include <strstrea.h>
7  #else
8 -#include <strstream.h>
9 +#include <strstream>
10  #endif
11  #include <stdio.h>
12  
13 diff -ru live/groupsock/NetInterface.cpp live-patched/groupsock/NetInterface.cpp
14 --- live/groupsock/NetInterface.cpp     Thu Nov  6 03:53:15 2003
15 +++ live-patched/groupsock/NetInterface.cpp     Sun Dec  7 21:30:30 2003
16 @@ -24,7 +24,7 @@
17  #if defined(__WIN32__) || defined(_WIN32)
18  #include <strstrea.h>
19  #else
20 -#include <strstream.h>
21 +#include <strstream>
22  #endif
23  
24  ////////// NetInterface //////////
25 --- live/liveMedia/RTSPClient.cpp       2007-04-24 11:38:22.000000000 +0200
26 +++ live-patched/liveMedia/RTSPClient.cpp       2007-04-26 15:19:54.000000000 +0200
27 @@ -21,13 +21,53 @@
28  #include "RTSPClient.hh"
29  #include "RTSPCommon.hh"
30  #include "Base64.hh"
31 -#include "Locale.hh"
32  #include <GroupsockHelper.hh>
33  #include "our_md5.h"
34  #ifdef SUPPORT_REAL_RTSP
35  #include "../RealRTSP/include/RealRTSP.hh"
36  #endif
37  
38 +#include <locale.h>
39 +#include <stdarg.h>
40 +/* Radix safe (always uses .) printf and friends */
41 +int radix_safe_sprintf( char *str, const char *format, ...)
42 +{
43 +     va_list args;
44 +     int result = 0;
45 +     char *locale = NULL;
46 +
47 +     locale = strDup( setlocale( LC_NUMERIC, NULL ) );
48 +     setlocale( LC_NUMERIC, "C" );
49 +
50 +     va_start( args, format );
51 +     result = vsprintf(str, format, args );
52 +     va_end( args );
53 +
54 +     setlocale( LC_NUMERIC, locale );
55 +     delete[] locale;
56 +
57 +     return result;
58 +}
59 +
60 +int radix_safe_sscanf( const char *str, const char *format, ...)
61 +{
62 +    va_list args;
63 +    int result = 0;
64 +    char *locale = NULL;
65 +
66 +    locale = strDup( setlocale( LC_NUMERIC, NULL ) );
67 +    setlocale( LC_NUMERIC, "C" );
68 +
69 +    va_start( args, format );
70 +    result = vsscanf(str, format, args );
71 +    va_end( args );
72 +
73 +    setlocale( LC_NUMERIC, locale );
74 +    delete[] locale;
75 +
76 +    return result;
77 +}
78 +
79  ////////// RTSPClient //////////
80  
81  RTSPClient* RTSPClient::createNew(UsageEnvironment& env,
82 @@ -989,8 +1029,7 @@
83      // This is the default value; we don't need a "Scale:" header:
84      buf[0] = '\0';
85    } else {
86 -    Locale("POSIX", LC_NUMERIC);
87 -    sprintf(buf, "Scale: %f\r\n", scale);
88 +    radix_safe_sprintf(buf, "Scale: %f\r\n", scale);
89    }
90  
91    return strDup(buf);
92 @@ -1003,12 +1042,10 @@
93      buf[0] = '\0';
94    } else if (end < 0) {
95      // There's no end time:
96 -    Locale("POSIX", LC_NUMERIC);
97 -    sprintf(buf, "Range: npt=%.3f-\r\n", start);
98 +    radix_safe_sprintf(buf, "Range: npt=%.3f-\r\n", start);
99    } else {
100      // There's both a start and an end time; include them both in the "Range:" hdr
101 -    Locale("POSIX", LC_NUMERIC);
102 -    sprintf(buf, "Range: npt=%.3f-%.3f\r\n", start, end);
103 +    radix_safe_sprintf(buf, "Range: npt=%.3f-%.3f\r\n", start, end);
104    }
105  
106    return strDup(buf);
107 @@ -2246,8 +2283,7 @@
108    if (_strncasecmp(line, "Scale: ", 7) != 0) return False;
109    line += 7;
110  
111 -  Locale("POSIX", LC_NUMERIC);
112 -  return sscanf(line, "%f", &scale) == 1;
113 +  return radix_safe_sscanf(line, "%f", &scale) == 1;
114  }
115  
116  Boolean RTSPClient::parseGetParameterHeader(char const* line, 
117 --- live/liveMedia/RTSPClient.cpp       2007-04-28 16:02:39.000000000 +0200
118 +++ live-patched/liveMedia/RTSPClient.cpp       2007-12-10 10:42:00.000000000 +0100
119 @@ -2074,7 +2076,8 @@ Boolean RTSPClient::getResponse(char con
120  unsigned RTSPClient::getResponse1(char*& responseBuffer,
121                                   unsigned responseBufferSize) {
122    struct sockaddr_in fromAddress;
123 -  
124 +  struct timeval timeout;
125 +
126    if (responseBufferSize == 0) return 0; // just in case...
127    responseBuffer[0] = '\0'; // ditto
128  
129 @@ -2084,7 +2087,9 @@ unsigned RTSPClient::getResponse1(char*&
130    Boolean success = False;
131    while (1) {
132      unsigned char firstByte;
133 -    if (readSocket(envir(), fInputSocketNum, &firstByte, 1, fromAddress)
134 +    timeout.tv_sec = 5;
135 +    timeout.tv_usec = 0;
136 +    if (readSocket(envir(), fInputSocketNum, &firstByte, 1, fromAddress, &timeout)
137         != 1) break;
138      if (firstByte != '$') {
139        // Normal case: This is the start of a regular response; use it: