mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-08 13:22:53 +02:00
avcodec/utils: add some saftey checks to add_metadata_from_side_data()
This fixes potential overreads with crafted files. Found-by: wm4 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
240fd8c96f
commit
838f461b07
@ -1952,10 +1952,17 @@ static int add_metadata_from_side_data(AVCodecContext *avctx, AVFrame *frame)
|
|||||||
if (!side_metadata)
|
if (!side_metadata)
|
||||||
goto end;
|
goto end;
|
||||||
end = side_metadata + size;
|
end = side_metadata + size;
|
||||||
|
if (size && end[-1])
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
while (side_metadata < end) {
|
while (side_metadata < end) {
|
||||||
const uint8_t *key = side_metadata;
|
const uint8_t *key = side_metadata;
|
||||||
const uint8_t *val = side_metadata + strlen(key) + 1;
|
const uint8_t *val = side_metadata + strlen(key) + 1;
|
||||||
int ret = av_dict_set(avpriv_frame_get_metadatap(frame), key, val, 0);
|
int ret;
|
||||||
|
|
||||||
|
if (val >= end)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
|
ret = av_dict_set(avpriv_frame_get_metadatap(frame), key, val, 0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
break;
|
break;
|
||||||
side_metadata = val + strlen(val) + 1;
|
side_metadata = val + strlen(val) + 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user