[FFmpeg-devel] [PATCH] Complain about and ignore obviously broken protocol size.
Michael Niedermayer
michaelni at gmx.at
Sat Dec 31 19:30:34 CET 2011
On Sat, Dec 31, 2011 at 07:19:13PM +0100, Reimar Döffinger wrote:
> On 31 Dec 2011, at 18:51, Michael Niedermayer <michaelni at gmx.at> wrote:
> > On Sat, Dec 31, 2011 at 06:07:23PM +0100, Reimar Döffinger wrote:
> >> 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");
> >
> > i dont think avio_size() is guranteed to be more than the current
> > position
>
> Ok with < then?
> Though it probably is a rare condition that ffio_limit will be called from EOF position.
> In theory I think my variant might "break" if it is called at position 0 with a broken protocol, but I don't like assuming that avio_size indicates always necessarily an error, for example a file still being downloaded can have size 0 at the beginning and still become playable later (though if ffio_limit is called while it's still 0 things probably are already broken...).
It does seem to be possible to seek beyond EOF, that seems to match
lseek() behavior
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The misfortune of the wise is better than the prosperity of the fool.
-- Epicurus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20111231/0f5c2454/attachment.asc>
More information about the ffmpeg-devel
mailing list