[vlc-commits] realrtsp: `rtsp_schedule_field` => bounds-check + error-check + diagnostic

Filip Roséen git at videolan.org
Fri Feb 26 20:46:48 CET 2016


vlc/vlc-2.2 | branch: master | Filip Roséen <filip at atch.se> | Thu Feb 25 10:12:36 2016 +0100| [6426315c9dc10cbf06dfb81d4a047d43ce5955cd] | committer: Jean-Baptiste Kempf

realrtsp: `rtsp_schedule_field` => bounds-check + error-check + diagnostic

The previous code would write out-of-bounds if the answered queue was full,
since the code expects there to be at least one NULL value among the fields
(something which is not guaranteed).

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
(cherry picked from commit dafabccf5282526e1579ce374ca5be590c26e89d)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/access/rtsp/rtsp.c |   22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/modules/access/rtsp/rtsp.c b/modules/access/rtsp/rtsp.c
index 82d0ed5..34bad2b 100644
--- a/modules/access/rtsp/rtsp.c
+++ b/modules/access/rtsp/rtsp.c
@@ -29,6 +29,8 @@
 #endif
 
 #include <vlc_common.h>
+#include <vlc_access.h>
+#include <vlc_messages.h>
 
 #include "rtsp.h"
 
@@ -636,15 +638,27 @@ char *rtsp_get_mrl( rtsp_client_t *rtsp )
  * schedules a field for transmission
  */
 
-void rtsp_schedule_field( rtsp_client_t *rtsp, const char *string )
+void rtsp_schedule_field( rtsp_client_t *rtsp, const char *data )
 {
+    access_t * p_access = (access_t*)rtsp->p_userdata;
+    char **pptr;
     int i = 0;
 
-    if( !string ) return;
+    if( rtsp->p_private == NULL || data == NULL)
+      return;
 
-    while( rtsp->p_private->scheduled[i] ) i++;
+    pptr = rtsp->p_private->scheduled;
 
-    rtsp->p_private->scheduled[i] = strdup(string);
+    for (i = 0; i < MAX_FIELDS; ++i) {
+      if (pptr[i] == NULL) {
+        pptr[i] = strdup(data);
+        break;
+      }
+    }
+
+    if (i == MAX_FIELDS) {
+      msg_Warn (p_access, "Unable to schedule '%s': the buffer is full!", data);
+    }
 }
 
 /*



More information about the vlc-commits mailing list