You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
avcodec/gifdec: truncate too big width/height for invalid gif files
Fixes #6874.
This commit is contained in:
@@ -179,12 +179,20 @@ static int gif_read_image(GifState *s, AVFrame *frame)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* verify that all the image is inside the screen dimensions */
|
/* verify that all the image is inside the screen dimensions */
|
||||||
if (!width || width > s->screen_width || left >= s->screen_width) {
|
if (!width || width > s->screen_width) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "Invalid image width.\n");
|
av_log(s->avctx, AV_LOG_WARNING, "Invalid image width: %d, truncating.\n", width);
|
||||||
|
width = s->screen_width;
|
||||||
|
}
|
||||||
|
if (left >= s->screen_width) {
|
||||||
|
av_log(s->avctx, AV_LOG_ERROR, "Invalid left position: %d.\n", left);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
if (!height || height > s->screen_height || top >= s->screen_height) {
|
if (!height || height > s->screen_height) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "Invalid image height.\n");
|
av_log(s->avctx, AV_LOG_WARNING, "Invalid image height: %d, truncating.\n", height);
|
||||||
|
height = s->screen_height;
|
||||||
|
}
|
||||||
|
if (top >= s->screen_height) {
|
||||||
|
av_log(s->avctx, AV_LOG_ERROR, "Invalid top position: %d.\n", top);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
if (left + width > s->screen_width) {
|
if (left + width > s->screen_width) {
|
||||||
|
Reference in New Issue
Block a user