forked from FFmpeg/FFmpeg
apedec: use unsigned int for offset
avoids implementation-defined unsigned-to-signed conversion and simplifies the bounds checking.
This commit is contained in:
parent
89ec474a43
commit
fd244ae3a0
1 changed files with 5 additions and 4 deletions
|
@ -813,7 +813,7 @@ static int ape_decode_frame(AVCodecContext *avctx,
|
||||||
APEContext *s = avctx->priv_data;
|
APEContext *s = avctx->priv_data;
|
||||||
int16_t *samples = data;
|
int16_t *samples = data;
|
||||||
uint32_t nblocks;
|
uint32_t nblocks;
|
||||||
int i, n;
|
int i;
|
||||||
int blockstodecode;
|
int blockstodecode;
|
||||||
int bytes_used;
|
int bytes_used;
|
||||||
|
|
||||||
|
@ -824,6 +824,7 @@ static int ape_decode_frame(AVCodecContext *avctx,
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!s->samples){
|
if(!s->samples){
|
||||||
|
uint32_t offset;
|
||||||
void *tmp_data = av_realloc(s->data, (buf_size + 3) & ~3);
|
void *tmp_data = av_realloc(s->data, (buf_size + 3) & ~3);
|
||||||
if (!tmp_data)
|
if (!tmp_data)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
@ -833,13 +834,13 @@ static int ape_decode_frame(AVCodecContext *avctx,
|
||||||
s->data_end = s->data + buf_size;
|
s->data_end = s->data + buf_size;
|
||||||
|
|
||||||
nblocks = bytestream_get_be32(&s->ptr);
|
nblocks = bytestream_get_be32(&s->ptr);
|
||||||
n = bytestream_get_be32(&s->ptr);
|
offset = bytestream_get_be32(&s->ptr);
|
||||||
if(n < 0 || n > 3){
|
if (offset > 3) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Incorrect offset passed\n");
|
av_log(avctx, AV_LOG_ERROR, "Incorrect offset passed\n");
|
||||||
s->data = NULL;
|
s->data = NULL;
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
s->ptr += n;
|
s->ptr += offset;
|
||||||
|
|
||||||
if (!nblocks || nblocks > INT_MAX) {
|
if (!nblocks || nblocks > INT_MAX) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Invalid sample count: %u.\n", nblocks);
|
av_log(avctx, AV_LOG_ERROR, "Invalid sample count: %u.\n", nblocks);
|
||||||
|
|
Loading…
Add table
Reference in a new issue