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

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sat Dec 31 16:40:49 CET 2011


This might fix trac issue #861.

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

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 517b852..f710164 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -270,11 +270,16 @@ 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;
+            }
             remaining= s->maxsize - avio_tell(s);
             remaining= FFMAX(remaining, 0);
         }
-- 
1.7.8.1



More information about the ffmpeg-devel mailing list