Le decadi 10 brumaire, an CCXXVI, Paul B Mahol a écrit : > Signed-off-by: Paul B Mahol <one...@gmail.com> > --- > libavfilter/vf_tile.c | 17 +++++++++++++---- > 1 file changed, 13 insertions(+), 4 deletions(-) > > diff --git a/libavfilter/vf_tile.c b/libavfilter/vf_tile.c > index 87e0b940cf..8eb0dc2097 100644 > --- a/libavfilter/vf_tile.c > +++ b/libavfilter/vf_tile.c > @@ -23,6 +23,7 @@ > * tile video filter > */ > > +#include "libavutil/imgutils.h" > #include "libavutil/opt.h" > #include "libavutil/pixdesc.h" > #include "avfilter.h" > @@ -44,8 +45,6 @@ typedef struct TileContext { > uint8_t rgba_color[4]; > } TileContext; > > -#define REASONABLE_SIZE 1024 > - > #define OFFSET(x) offsetof(TileContext, x) > #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM > > @@ -68,12 +67,21 @@ static av_cold int init(AVFilterContext *ctx) > { > TileContext *tile = ctx->priv; > > - if (tile->w > REASONABLE_SIZE || tile->h > REASONABLE_SIZE) {
> + if (tile->w > UINT32_MAX / tile->h) { All the variables are of type unsigned, not uint32_t; therefore, the correct limit would be UINT_MAX. > av_log(ctx, AV_LOG_ERROR, "Tile size %ux%u is insane.\n", > tile->w, tile->h); > return AVERROR(EINVAL); > } > > + if (tile->padding) { > + if ((tile->w - 1 > (UINT32_MAX - 2 * tile->margin) / tile->padding) > || > + (tile->h - 1 > (UINT32_MAX - 2 * tile->margin) / tile->padding)) > { > + av_log(ctx, AV_LOG_ERROR, "Combination of Tile size %ux%u, > padding %d and margin %d overflows.\n", > + tile->w, tile->h, tile->padding, tile->margin); > + return AVERROR(EINVAL); > + } > + } > + > if (tile->nb_frames == 0) { > tile->nb_frames = tile->w * tile->h; > } else if (tile->nb_frames > tile->w * tile->h) { > @@ -116,7 +124,7 @@ static int config_props(AVFilterLink *outlink) > ff_draw_init(&tile->draw, inlink->format, 0); > ff_draw_color(&tile->draw, &tile->blank, tile->rgba_color); > > - return 0; > + return av_image_check_size2(outlink->w, outlink->h, INT64_MAX, > inlink->format, 0, ctx); This is no longer necessary now it is done for all filters. > } > > static void get_current_tile_pos(AVFilterContext *ctx, unsigned *x, unsigned > *y) > @@ -142,6 +150,7 @@ static void draw_blank_frame(AVFilterContext *ctx, > AVFrame *out_buf) > x0, y0, inlink->w, inlink->h); > tile->current++; > } > + > static int end_last_frame(AVFilterContext *ctx) > { > TileContext *tile = ctx->priv; LGTM now. Thanks for your efforts. Regards, -- Nicolas George
signature.asc
Description: Digital signature
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel