Ticket #5527: delogo-check-parameters-2.patch

File delogo-check-parameters-2.patch, 1.4 KB (added by Jean Delvare, 10 years ago)

[PATCH] avfilter/delogo: Check that logo area is inside the picture

  • libavfilter/vf_delogo.c

    From: Jean Delvare <jdelvare@suse.com>
    Subject: avfilter/delogo: Check that logo area is inside the picture
    
    We can only remove the logo if it is inside the picture. We need at
    least one pixel around the logo area for interpolation.
    
    Fixes ticket #5527 (Delogo crash with x=0 and/or y=0).
    
    Signed-off-by: Jean Delvare <jdelvare@suse.com>
    ---
     libavfilter/vf_delogo.c |   15 +++++++++++++++
     1 file changed, 15 insertions(+)
    
    old new static av_cold int init(AVFilterContext  
    225225    return 0;
    226226}
    227227
     228static int config_input(AVFilterLink *inlink)
     229{
     230    DelogoContext *s = inlink->dst->priv;
     231
     232    /* Check whether the logo area fits in the frame */
     233    if (s->x + (s->band - 1) < 0 || s->x + s->w - (s->band*2 - 2) > inlink->w ||
     234        s->y + (s->band - 1) < 0 || s->y + s->h - (s->band*2 - 2) > inlink->h) {
     235        av_log(s, AV_LOG_ERROR, "Logo area is outside of the frame.\n");
     236        return AVERROR(EINVAL);
     237    }
     238
     239    return 0;
     240}
     241
    228242static int filter_frame(AVFilterLink *inlink, AVFrame *in)
    229243{
    230244    DelogoContext *s = inlink->dst->priv;
    static const AVFilterPad avfilter_vf_del  
    283297        .name         = "default",
    284298        .type         = AVMEDIA_TYPE_VIDEO,
    285299        .filter_frame = filter_frame,
     300        .config_props = config_input,
    286301    },
    287302    { NULL }
    288303};