[FFmpeg-devel] [PATCH] Complain about and ignore obviously broken protocol size.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sat Dec 31 18:07:23 CET 2011


Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
---
 libavformat/utils.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 517b852..9228821 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -270,11 +270,15 @@ AVInputFormat *av_find_input_format(const char *short_name)
 int ffio_limit(AVIOContext *s, int size)
 {
     if(s->maxsize>=0){
-        int64_t remaining= s->maxsize - avio_tell(s);
+        int64_t pos = avio_tell(s);
+        int64_t remaining= s->maxsize - pos;
         if(remaining < size){
             int64_t newsize= avio_size(s);
-            if(!s->maxsize || s->maxsize<newsize)
-                s->maxsize= newsize - !newsize;
+            if(newsize >= 0 && newsize <= pos) {
+                av_log(0, AV_LOG_ERROR, "Broken protocol implementation, size <= pos\n");
+                s->maxsize= -1;
+            } else if(!s->maxsize || s->maxsize<newsize)
+                s->maxsize= newsize;
             remaining= s->maxsize - avio_tell(s);
             remaining= FFMAX(remaining, 0);
         }
-- 
1.7.8.1



More information about the ffmpeg-devel mailing list