rtmp: Return an error when the client bandwidth is incorrect
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 25 Jul 2012 18:51:11 +0000 (20:51 +0200)
committerMartin Storsjö <martin@martin.st>
Wed, 25 Jul 2012 20:57:01 +0000 (23:57 +0300)
Signed-off-by: Martin Storsjö <martin@martin.st>
libavformat/rtmpproto.c

index 5ac60d2..a2efe38 100644 (file)
@@ -932,8 +932,16 @@ static int handle_client_bw(URLContext *s, RTMPPacket *pkt)
                pkt->data_size);
         return AVERROR_INVALIDDATA;
     }
-    av_log(s, AV_LOG_DEBUG, "Client bandwidth = %d\n", AV_RB32(pkt->data));
-    rt->client_report_size = AV_RB32(pkt->data) >> 1;
+
+    rt->client_report_size = AV_RB32(pkt->data);
+    if (rt->client_report_size <= 0) {
+        av_log(s, AV_LOG_ERROR, "Incorrect client bandwidth %d\n",
+                rt->client_report_size);
+        return AVERROR_INVALIDDATA;
+
+    }
+    av_log(s, AV_LOG_DEBUG, "Client bandwidth = %d\n", rt->client_report_size);
+    rt->client_report_size >>= 1;
 
     return 0;
 }