[vlc-commits] contrib: live555: Fix undefined behaviors

Hugo Beauzée-Luyssen git at videolan.org
Fri Nov 24 16:28:50 CET 2017


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Fri Nov 24 15:03:33 2017 +0100| [d192a702d6c9ddaf0ba7b55cbd6006e6189dc7a1] | committer: Hugo Beauzée-Luyssen

contrib: live555: Fix undefined behaviors

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d192a702d6c9ddaf0ba7b55cbd6006e6189dc7a1
---

 contrib/src/live555/no-null-reference.patch | 128 ++++++++++++++++++++++++++++
 contrib/src/live555/rules.mak               |   2 +
 2 files changed, 130 insertions(+)

diff --git a/contrib/src/live555/no-null-reference.patch b/contrib/src/live555/no-null-reference.patch
new file mode 100644
index 0000000000..a1dea30fbc
--- /dev/null
+++ b/contrib/src/live555/no-null-reference.patch
@@ -0,0 +1,128 @@
+--- live555/liveMedia/RTSPClient.cpp.old	2017-11-24 14:34:20.588181348 +0100
++++ live555/liveMedia/RTSPClient.cpp	2017-11-24 14:56:37.520204839 +0100
+@@ -183,13 +183,13 @@
+   }
+ }
+ 
+-void RTSPClient::setSpeed(MediaSession& session, float speed) { 
++void RTSPClient::setSpeed(MediaSession* session, float speed) {
+   // Optionally set download speed for session to be used later on PLAY command:
+   // The user should call this function after the MediaSession is instantiated, but before the
+   // first "sendPlayCommand()" is called.
+-  if (&session != NULL) {
+-    session.speed() = speed;
+-    MediaSubsessionIterator iter(session);
++  if (session != NULL) {
++    session->speed() = speed;
++    MediaSubsessionIterator iter(*session);
+     MediaSubsession* subsession;
+ 
+     while ((subsession = iter.next()) != NULL) {
+@@ -1215,26 +1215,26 @@
+   return success;
+ }
+ 
+-Boolean RTSPClient::handlePLAYResponse(MediaSession& session, MediaSubsession& subsession,
++Boolean RTSPClient::handlePLAYResponse(MediaSession* session, MediaSubsession* subsession,
+                                        char const* scaleParamsStr, char const* speedParamsStr,
+                                        char const* rangeParamsStr, char const* rtpInfoParamsStr) {
+   Boolean scaleOK = False, rangeOK = False, speedOK = False;
+   do {
+-    if (&session != NULL) {
++    if (session != NULL) {
+       // The command was on the whole session
+-      if (scaleParamsStr != NULL && !parseScaleParam(scaleParamsStr, session.scale())) break;
++      if (scaleParamsStr != NULL && !parseScaleParam(scaleParamsStr, session->scale())) break;
+       scaleOK = True;
+-      if (speedParamsStr != NULL && !parseSpeedParam(speedParamsStr, session.speed())) break;
++      if (speedParamsStr != NULL && !parseSpeedParam(speedParamsStr, session->speed())) break;
+       speedOK = True;
+       Boolean startTimeIsNow;
+       if (rangeParamsStr != NULL &&
+ 	  !parseRangeParam(rangeParamsStr,
+-			   session.playStartTime(), session.playEndTime(),
+-			   session._absStartTime(), session._absEndTime(),
++               session->playStartTime(), session->playEndTime(),
++               session->_absStartTime(), session->_absEndTime(),
+ 			   startTimeIsNow)) break;
+       rangeOK = True;
+ 
+-      MediaSubsessionIterator iter(session);
++      MediaSubsessionIterator iter(*session);
+       MediaSubsession* subsession;
+       while ((subsession = iter.next()) != NULL) {
+ 	u_int16_t seqNum; u_int32_t timestamp;
+@@ -1249,27 +1249,27 @@
+       }
+     } else {
+       // The command was on a subsession
+-      if (scaleParamsStr != NULL && !parseScaleParam(scaleParamsStr, subsession.scale())) break;
++      if (scaleParamsStr != NULL && !parseScaleParam(scaleParamsStr, subsession->scale())) break;
+       scaleOK = True;
+-      if (speedParamsStr != NULL && !parseSpeedParam(speedParamsStr, session.speed())) break;
++      if (speedParamsStr != NULL && !parseSpeedParam(speedParamsStr, subsession->speed())) break;
+       speedOK = True;
+       Boolean startTimeIsNow;
+       if (rangeParamsStr != NULL &&
+ 	  !parseRangeParam(rangeParamsStr,
+-			   subsession._playStartTime(), subsession._playEndTime(),
+-			   subsession._absStartTime(), subsession._absEndTime(),
++               subsession->_playStartTime(), subsession->_playEndTime(),
++               subsession->_absStartTime(), subsession->_absEndTime(),
+ 			   startTimeIsNow)) break;
+       rangeOK = True;
+ 
+       u_int16_t seqNum; u_int32_t timestamp;
+-      subsession.rtpInfo.infoIsNew = False;
++      subsession->rtpInfo.infoIsNew = False;
+       if (parseRTPInfoParams(rtpInfoParamsStr, seqNum, timestamp)) {
+-	subsession.rtpInfo.seqNum = seqNum;
+-	subsession.rtpInfo.timestamp = timestamp;
+-	subsession.rtpInfo.infoIsNew = True;
++    subsession->rtpInfo.seqNum = seqNum;
++    subsession->rtpInfo.timestamp = timestamp;
++    subsession->rtpInfo.infoIsNew = True;
+       }
+ 
+-      if (subsession.rtpSource() != NULL) subsession.rtpSource()->enableRTCPReports() = True; // start sending RTCP "RR"s now
++      if (subsession->rtpSource() != NULL) subsession->rtpSource()->enableRTCPReports() = True; // start sending RTCP "RR"s now
+     }
+ 
+     return True;
+@@ -1809,12 +1809,12 @@
+ 	if (responseCode == 200) {
+ 	  // Do special-case response handling for some commands:
+ 	  if (strcmp(foundRequest->commandName(), "SETUP") == 0) {
+-	    if (!handleSETUPResponse(*foundRequest->subsession(), sessionParamsStr, transportParamsStr, foundRequest->booleanFlags()&0x1)) break;
++        if (!handleSETUPResponse(*foundRequest->subsession(), sessionParamsStr, transportParamsStr, foundRequest->booleanFlags()&0x1)) break;
+ 	  } else if (strcmp(foundRequest->commandName(), "PLAY") == 0) {
+-	    if (!handlePLAYResponse(*foundRequest->session(), *foundRequest->subsession(), scaleParamsStr, speedParamsStr, rangeParamsStr, rtpInfoParamsStr)) break;
++        if (!handlePLAYResponse(foundRequest->session(), foundRequest->subsession(), scaleParamsStr, speedParamsStr, rangeParamsStr, rtpInfoParamsStr)) break;
+ 	  } else if (strcmp(foundRequest->commandName(), "TEARDOWN") == 0) {
+-	    if (!handleTEARDOWNResponse(*foundRequest->session(), *foundRequest->subsession())) break;
+-	  } else if (strcmp(foundRequest->commandName(), "GET_PARAMETER") == 0) {
++        if (!handleTEARDOWNResponse(*foundRequest->session(), *foundRequest->subsession())) break;
++      } else if (strcmp(foundRequest->commandName(), "GET_PARAMETER") == 0) {
+ 	    if (!handleGET_PARAMETERResponse(foundRequest->contentStr(), bodyStart, responseEnd)) break;
+ 	  }
+ 	} else if (responseCode == 401 && handleAuthenticationFailure(wwwAuthenticateParamsStr)) {
+--- live555/liveMedia/include/RTSPClient.hh.old.h	2017-11-24 14:48:30.544196283 +0100
++++ live555/liveMedia/include/RTSPClient.hh	2017-11-24 14:56:57.836205196 +0100
+@@ -155,7 +155,7 @@
+       // Our implementation automatically does this just prior to sending each "PLAY" command;
+       // You should not call these functions yourself unless you know what you're doing.
+ 
+-  void setSpeed(MediaSession& session, float speed = 1.0f);
++  void setSpeed(MediaSession* session, float speed = 1.0f);
+       // Set (recorded) media download speed to given value to support faster download using 'Speed:'
+       // option on 'PLAY' command.
+ 
+@@ -286,7 +286,7 @@
+   Boolean parseRTPInfoParams(char const*& paramStr, u_int16_t& seqNum, u_int32_t& timestamp);
+   Boolean handleSETUPResponse(MediaSubsession& subsession, char const* sessionParamsStr, char const* transportParamsStr,
+ 			      Boolean streamUsingTCP);
+-  Boolean handlePLAYResponse(MediaSession& session, MediaSubsession& subsession,
++  Boolean handlePLAYResponse(MediaSession* session, MediaSubsession* subsession,
+                              char const* scaleParamsStr, const char* speedParamsStr,
+ 			     char const* rangeParamsStr, char const* rtpInfoParamsStr);
+   Boolean handleTEARDOWNResponse(MediaSession& session, MediaSubsession& subsession);
diff --git a/contrib/src/live555/rules.mak b/contrib/src/live555/rules.mak
index 19d04541d8..c389f2c33d 100644
--- a/contrib/src/live555/rules.mak
+++ b/contrib/src/live555/rules.mak
@@ -66,6 +66,8 @@ endif
 	$(APPLY) $(SRC)/live555/live555-nosignal.patch
 	# Don't use FormatMessageA on WinRT
 	$(APPLY) $(SRC)/live555/winstore.patch
+	# Don't rely on undefined behaviors
+	$(APPLY) $(SRC)/live555/no-null-reference.patch
 	# Add a pkg-config file
 	$(APPLY) $(SRC)/live555/add-pkgconfig-file.patch
 



More information about the vlc-commits mailing list