gstrtspconnection: Security loophole making heap overflow
authorTobias Ronge <tobiasr@axis.com>
Thu, 14 Mar 2019 09:12:27 +0000 (10:12 +0100)
committerTobias Ronge <tobiasr@axis.com>
Thu, 14 Mar 2019 09:24:30 +0000 (10:24 +0100)
The former code allowed an attacker to create a heap overflow by
sending a longer than allowed session id in a response and including a
semicolon to change the maximum length. With this change, the parser
will never go beyond 512 bytes.

gst-libs/gst/rtsp/gstrtspconnection.c

index a6755be..c042906 100644 (file)
@@ -2461,7 +2461,7 @@ build_next (GstRTSPBuilder * builder, GstRTSPMessage * message,
           maxlen = sizeof (conn->session_id) - 1;
           /* the sessionid can have attributes marked with ;
            * Make sure we strip them */
-          for (i = 0; session_id[i] != '\0'; i++) {
+          for (i = 0; i < maxlen && session_id[i] != '\0'; i++) {
             if (session_id[i] == ';') {
               maxlen = i;
               /* parse timeout */