[vlc-devel] [PATCH 02/13] modules/access/rtsp: Fixed crash when 'RealChallenge1' is missing from initial server reply

Filip Roséen filip at atch.se
Thu Feb 25 10:12:28 CET 2016


The module would crash if the remote server did not include `RealChallenge1` in
the headers of the initial reply after establishing a connection. The below is a
sample testcase.

  % nc -l -p 8080 <<EOF
  > RTSP/1.0 200 OK
  > Server: Real
  >
  > EOF

  $ vlc -Idummy --access realrtps,none rtsp://localhost:8080/test
  VLC media player 3.0.0-git Vetinari (revision 2.2.0-git-6509-g6e5cfeb)
  [0000000001da3e58] dummy interface: using the dummy interface module...
  [00007fdaac001198] core access error: connection failed: Connection refused
  zsh: segmentation fault (core dumped) vlc -Idummy --access realrtsp,none 'rtsp://localhost:8080/test'
---
 modules/access/rtsp/real.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/modules/access/rtsp/real.c b/modules/access/rtsp/real.c
index 0cec65c..0b7d5cc 100644
--- a/modules/access/rtsp/real.c
+++ b/modules/access/rtsp/real.c
@@ -622,10 +622,17 @@ rmff_header_t  *real_setup_and_get_header(rtsp_client_t *rtsp_session, int bandw
   char *mrl=rtsp_get_mrl(rtsp_session);
   unsigned int size;
   int status;
+  char *p_data;
 
   /* get challenge */
-  challenge1=strdup(rtsp_search_answers(rtsp_session,"RealChallenge1"));
-  msg_Dbg(p_access, "Challenge1: %s", challenge1);
+  if (NULL == (p_data = rtsp_search_answers(rtsp_session, "RealChallenge1"))) {
+    msg_Warn(p_access, "server did not reply with RealChallenge1, aborting!");
+    return NULL;
+
+  } else {
+    challenge1 = strdup(p_data);
+    msg_Dbg(p_access, "Challenge1: %s", challenge1);
+  }
 
   sprintf(buf, "Bandwidth: %u", bandwidth);
 
-- 
2.7.1



More information about the vlc-devel mailing list