mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-28 20:53:54 +02:00
avcodec/avcodec: Limit the number of side data elements per packet
Fixes: 1293/clusterfuzz-testcase-minimized-6054752074858496
See: [FFmpeg-devel] [PATCH] avcodec/avcodec: Limit the number of side data elements per packet
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d5711cb891
)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
3526d25017
commit
5121f31cac
@ -1583,6 +1583,16 @@ enum AVPacketSideDataType {
|
|||||||
* to the AVSphericalMapping structure.
|
* to the AVSphericalMapping structure.
|
||||||
*/
|
*/
|
||||||
AV_PKT_DATA_SPHERICAL,
|
AV_PKT_DATA_SPHERICAL,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of side data elements (in fact a bit more than it).
|
||||||
|
* This is not part of the public API/ABI in the sense that it may
|
||||||
|
* change when new side data types are added.
|
||||||
|
* This must stay the last enum value.
|
||||||
|
* If its value becomes huge, some code using it
|
||||||
|
* needs to be updated as it assumes it to be smaller than other limits.
|
||||||
|
*/
|
||||||
|
AV_PKT_DATA_NB
|
||||||
};
|
};
|
||||||
|
|
||||||
#define AV_PKT_DATA_QUALITY_FACTOR AV_PKT_DATA_QUALITY_STATS //DEPRECATED
|
#define AV_PKT_DATA_QUALITY_FACTOR AV_PKT_DATA_QUALITY_STATS //DEPRECATED
|
||||||
|
@ -298,7 +298,7 @@ int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
|
|||||||
AVPacketSideData *tmp;
|
AVPacketSideData *tmp;
|
||||||
int elems = pkt->side_data_elems;
|
int elems = pkt->side_data_elems;
|
||||||
|
|
||||||
if ((unsigned)elems + 1 > INT_MAX / sizeof(*pkt->side_data))
|
if ((unsigned)elems + 1 > AV_PKT_DATA_NB)
|
||||||
return AVERROR(ERANGE);
|
return AVERROR(ERANGE);
|
||||||
|
|
||||||
tmp = av_realloc(pkt->side_data, (elems + 1) * sizeof(*tmp));
|
tmp = av_realloc(pkt->side_data, (elems + 1) * sizeof(*tmp));
|
||||||
@ -436,6 +436,9 @@ int av_packet_split_side_data(AVPacket *pkt){
|
|||||||
p-= size+5;
|
p-= size+5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (i > AV_PKT_DATA_NB)
|
||||||
|
return AVERROR(ERANGE);
|
||||||
|
|
||||||
pkt->side_data = av_malloc_array(i, sizeof(*pkt->side_data));
|
pkt->side_data = av_malloc_array(i, sizeof(*pkt->side_data));
|
||||||
if (!pkt->side_data)
|
if (!pkt->side_data)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
Loading…
Reference in New Issue
Block a user