[vlc-commits] rtsp: avoid hardcoding buffer size

Arjun Sreedharan git at videolan.org
Sun Jun 14 19:22:31 CEST 2015


vlc/vlc-2.2 | branch: master | Arjun Sreedharan <arjun024 at gmail.com> | Thu Jun 11 17:21:32 2015 +0530| [2108feefa9111e4ba9a284b20cfc1f55985b08de] | committer: Jean-Baptiste Kempf

rtsp: avoid hardcoding buffer size

also maintain uniform case "CSeq" throughout.

Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>
(cherry picked from commit c932b5e7eaf9a681b043cd7ee258ecdfe71542e2)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/access/rtsp/rtsp.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/modules/access/rtsp/rtsp.c b/modules/access/rtsp/rtsp.c
index 1c8d0f1..f044a9d 100644
--- a/modules/access/rtsp/rtsp.c
+++ b/modules/access/rtsp/rtsp.c
@@ -187,9 +187,9 @@ static int rtsp_send_request( rtsp_client_t *rtsp, const char *psz_type,
 
 static void rtsp_schedule_standard( rtsp_client_t *rtsp )
 {
-    char tmp[17];
+    char tmp[sizeof("CSeq: ") + 3 * sizeof(int)];
 
-    sprintf( tmp, "Cseq: %u", rtsp->p_private->cseq);
+    sprintf( tmp, "CSeq: %u", rtsp->p_private->cseq);
     rtsp_schedule_field( rtsp, tmp );
 
     if( rtsp->p_private->session )
@@ -226,7 +226,7 @@ static int rtsp_get_answers( rtsp_client_t *rtsp )
       answer = rtsp_get( rtsp );
       if( !answer ) return 0;
 
-      if( !strncasecmp( answer, "Cseq:", 5 ) )
+      if( !strncasecmp( answer, "CSeq:", 5 ) )
       {
           sscanf( answer, "%*s %u", &answer_seq );
           if( rtsp->p_private->cseq != answer_seq )
@@ -284,7 +284,7 @@ static int rtsp_get_answers( rtsp_client_t *rtsp )
 
 int rtsp_send_ok( rtsp_client_t *rtsp )
 {
-    char cseq[17];
+    char cseq[sizeof("CSeq: ") + 3 * sizeof(int)];
 
     rtsp_put( rtsp, "RTSP/1.0 200 OK" );
     sprintf( cseq, "CSeq: %u", rtsp->p_private->cseq );
@@ -418,7 +418,7 @@ int rtsp_read_data( rtsp_client_t *rtsp, uint8_t *buffer, unsigned int size )
                 rest = rtsp_get( rtsp );
                 if( !rest ) return -1;
 
-                if( !strncasecmp( rest, "Cseq:", 5 ) )
+                if( !strncasecmp( rest, "CSeq:", 5 ) )
                     sscanf( rest, "%*s %u", &seq );
             } while( *rest );
             free( rest );
@@ -431,7 +431,7 @@ int rtsp_read_data( rtsp_client_t *rtsp, uint8_t *buffer, unsigned int size )
 
             /* lets make the server happy */
             rtsp_put( rtsp, "RTSP/1.0 451 Parameter Not Understood" );
-            rest = xmalloc(17);
+            rest = xmalloc(sizeof("Cseq: ") + 3 * sizeof(int));
             sprintf( rest,"CSeq: %u", seq );
             rtsp_put( rtsp, rest );
             rtsp_put( rtsp, "" );



More information about the vlc-commits mailing list