[FFmpeg-devel] [PATCH] wtvenc: test avio_size() validity
Peter Ross
pross at xvid.org
Mon Dec 23 11:04:45 CET 2013
---
On Sun, Dec 22, 2013 at 08:10:54AM +0100, Reimar Döffinger wrote:
> On 21.12.2013, at 09:42, Peter Ross <pross at xvid.org> wrote:
> > Previously the demuxer was testing against avio_tell, and this would generate
> > many false warnings.
>
> Do we support streaming (or otherwise non-seekable) wtv files?
Not currently. The filesystem-like nature of wtv means that (lots of) seeking is almost always
required. It is theorectically to craft a file that does require seeking.
> I suspect not, but to be correct for that case it would need to check that avio_size is valid first...
I agree.
libavformat/wtvdec.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
index 5069d48..21236fa 100644
--- a/libavformat/wtvdec.c
+++ b/libavformat/wtvdec.c
@@ -153,6 +153,7 @@ static AVIOContext * wtvfile_open_sector(int first_sector, uint64_t length, int
AVIOContext *pb;
WtvFile *wf;
uint8_t *buffer;
+ int64_t size;
if (seek_by_sector(s->pb, first_sector, 0) < 0)
return NULL;
@@ -205,7 +206,8 @@ static AVIOContext * wtvfile_open_sector(int first_sector, uint64_t length, int
return NULL;
}
- if ((int64_t)wf->sectors[wf->nb_sectors - 1] << WTV_SECTOR_BITS > avio_size(s->pb))
+ size = avio_size(s->pb);
+ if (size >= 0 && (int64_t)wf->sectors[wf->nb_sectors - 1] << WTV_SECTOR_BITS > size)
av_log(s, AV_LOG_WARNING, "truncated file\n");
/* check length */
--
1.8.3.2
-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
-------------- 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/20131223/85781e43/attachment.asc>
More information about the ffmpeg-devel
mailing list