diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2006-05-13 11:37:56 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2006-05-13 11:37:56 +0000 |
commit | a443a2530d00b7019269202ac0f5ca8ba0a021c7 (patch) | |
tree | 9dfe3c9388c09a10ef32b64a871d3dac45495cb5 /libavformat/tta.c | |
parent | 3a1a7e32ace7af47de74e8ae779cb4e04c89aa97 (diff) | |
download | ffmpeg-a443a2530d00b7019269202ac0f5ca8ba0a021c7.tar.gz |
sanity checks some might have been exploitable
Originally committed as revision 5370 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/tta.c')
-rw-r--r-- | libavformat/tta.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libavformat/tta.c b/libavformat/tta.c index 5d3dc4d828..203e47eb16 100644 --- a/libavformat/tta.c +++ b/libavformat/tta.c @@ -50,13 +50,27 @@ static int tta_read_header(AVFormatContext *s, AVFormatParameters *ap) channels = get_le16(&s->pb); bps = get_le16(&s->pb); samplerate = get_le32(&s->pb); + if(samplerate <= 0 || samplerate > 1000000){ + av_log(s, AV_LOG_ERROR, "nonsense samplerate\n"); + return -1; + } + datalen = get_le32(&s->pb); + if(datalen < 0){ + av_log(s, AV_LOG_ERROR, "nonsense datalen\n"); + return -1; + } + url_fskip(&s->pb, 4); // header crc framelen = 1.04489795918367346939 * samplerate; c->totalframes = datalen / framelen + ((datalen % framelen) ? 1 : 0); c->currentframe = 0; + if(c->totalframes >= UINT_MAX/sizeof(uint32_t)){ + av_log(s, AV_LOG_ERROR, "totalframes too large\n"); + return -1; + } c->seektable = av_mallocz(sizeof(uint32_t)*c->totalframes); if (!c->seektable) return AVERROR_NOMEM; @@ -76,6 +90,11 @@ static int tta_read_header(AVFormatContext *s, AVFormatParameters *ap) st->codec->bits_per_sample = bps; st->codec->extradata_size = url_ftell(&s->pb) - start; + if(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)st->codec->extradata_size){ + //this check is redundant as get_buffer should fail + av_log(s, AV_LOG_ERROR, "extradata_size too large\n"); + return -1; + } st->codec->extradata = av_mallocz(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE); url_fseek(&s->pb, start, SEEK_SET); // or SEEK_CUR and -size ? :) get_buffer(&s->pb, st->codec->extradata, st->codec->extradata_size); |