diff options
| author | Tim Redfern <tim@eclectronics.org> | 2013-12-29 12:19:38 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2013-12-29 12:19:38 +0000 |
| commit | f7813a5324be39d13ab536c245d15dfc602a7849 (patch) | |
| tree | fad99148b88823d34a5df2f0a25881a002eb291b /ffmpeg/libavformat/swfdec.c | |
| parent | b7a5a477b8ff4d4e3028b9dfb9a9df0a41463f92 (diff) | |
basic type mechanism working
Diffstat (limited to 'ffmpeg/libavformat/swfdec.c')
| -rw-r--r-- | ffmpeg/libavformat/swfdec.c | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/ffmpeg/libavformat/swfdec.c b/ffmpeg/libavformat/swfdec.c index 54e0f6d..c95b18e 100644 --- a/ffmpeg/libavformat/swfdec.c +++ b/ffmpeg/libavformat/swfdec.c @@ -55,12 +55,18 @@ static int get_swf_tag(AVIOContext *pb, int *len_ptr) static int swf_probe(AVProbeData *p) { + if(p->buf_size < 15) + return 0; + /* check file header */ - if ((p->buf[0] == 'F' || p->buf[0] == 'C') && p->buf[1] == 'W' && - p->buf[2] == 'S') - return AVPROBE_SCORE_MAX; - else + if ( AV_RB24(p->buf) != AV_RB24("CWS") + && AV_RB24(p->buf) != AV_RB24("FWS")) return 0; + + if (p->buf[3] >= 20) + return AVPROBE_SCORE_MAX / 4; + + return AVPROBE_SCORE_MAX; } #if CONFIG_ZLIB @@ -440,16 +446,30 @@ bitmap_end_skip: goto skip; if ((res = av_new_packet(pkt, len)) < 0) return res; - avio_read(pb, pkt->data, 4); + if (avio_read(pb, pkt->data, 4) != 4) { + av_free_packet(pkt); + return AVERROR_INVALIDDATA; + } if (AV_RB32(pkt->data) == 0xffd8ffd9 || AV_RB32(pkt->data) == 0xffd9ffd8) { /* old SWF files containing SOI/EOI as data start */ /* files created by swink have reversed tag */ pkt->size -= 4; - avio_read(pb, pkt->data, pkt->size); + memset(pkt->data+pkt->size, 0, 4); + res = avio_read(pb, pkt->data, pkt->size); } else { - avio_read(pb, pkt->data + 4, pkt->size - 4); + res = avio_read(pb, pkt->data + 4, pkt->size - 4); + if (res >= 0) + res += 4; + } + if (res != pkt->size) { + if (res < 0) { + av_free_packet(pkt); + return res; + } + av_shrink_packet(pkt, res); } + pkt->pos = pos; pkt->stream_index = st->index; return pkt->size; |
