From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <ffmpeg-devel-bounces@ffmpeg.org>
Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100])
	by master.gitmailbox.com (Postfix) with ESMTP id 3CCA145D58
	for <ffmpegdev@gitmailbox.com>; Wed,  7 Jun 2023 07:03:05 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8ECBE68C307;
	Wed,  7 Jun 2023 10:03:02 +0300 (EEST)
Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com
 [209.85.222.170])
 by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 09B2368C171
 for <ffmpeg-devel@ffmpeg.org>; Wed,  7 Jun 2023 10:02:56 +0300 (EEST)
Received: by mail-qk1-f170.google.com with SMTP id
 af79cd13be357-75ec7e8e826so191618485a.0
 for <ffmpeg-devel@ffmpeg.org>; Wed, 07 Jun 2023 00:02:55 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20221208; t=1686121374; x=1688713374;
 h=to:subject:message-id:date:from:in-reply-to:references:mime-version
 :from:to:cc:subject:date:message-id:reply-to;
 bh=OXMbtHsnYS9VFXjpT8hCBRf4ybu/UlWzjAuMcmHpPkY=;
 b=gT1KmmAr1K+5zHzU28anq8x85Ds/gQyVn4bmxPv6Z8Hq3DGa4WCl1zujUom0iJdtMt
 J9YY2gA3LNGkm0oYcYM/ypSUoekLYB5SOHQaXipFPxEw13NmFIR027oV3lrXiOh/0Ld5
 rUY1u0rQ6aMsXeSfxqHsGMmXBsz5rq+mfxzJIsiwfp41UlJbRrr/qpqcCTGzV7DhbSnh
 RNkdYcdIK5Z+bA1+HOvYqDcvfSYWAzwUE1yWfux+T20JeoJ0fZxA5yFcvo6TdtAb0iwI
 vwOMB8Pqra9S93Dl5DO47agzihjK2sKoD318DtCJrD5jBWBK7sQWEqmP/2IIdpbVJjYv
 xXJA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20221208; t=1686121374; x=1688713374;
 h=to:subject:message-id:date:from:in-reply-to:references:mime-version
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=OXMbtHsnYS9VFXjpT8hCBRf4ybu/UlWzjAuMcmHpPkY=;
 b=ImXaL2trfvG1fymCJSduEBOONSklAosTg+HFu+c0XyzDnaT0gC9Mua9PTxH4Ijoa3c
 aRKKlHRLdaFOFQg8yHWeugXNWVxKa0UX78+wcfQNOdi/IYEw2QcZeBddk04nQ92UULUr
 fb3HJSAFERBgfoPQIRvsJQQx5sYdN5xHTx+pXZTKlYcWvv5qfsOBO/yQnl0vdplYLQ2O
 nW5IGNDOOJKSmWTZPd63ZyH72CNgNdmi2twv4wNFwbariui2dYgi69TMFKZhzUgEm5n3
 r7Wrrw5TR+li5btCLt5/gTKEZeTbxP9lqVwf4TN8AiZbNvyOo66IEci5OZ27xhoY0c3h
 jvqg==
X-Gm-Message-State: AC+VfDzfLbXxVqKv5FTIjaNNpVW9DHyndd02yxyQ8CHsuWRYLoKxCxgX
 X16TWQHLasOUClVkOX8wVe0hS1GAF2kgObdBVAe/mx0rDj8=
X-Google-Smtp-Source: ACHHUZ5PSx1D8EoDnXpeRXi9SolWN4916LCBavxarxOn3qIPwUEYhvZb3q8tfO+1jTRfQO6t1LAXCrqDUot9jn7RztI=
X-Received: by 2002:a05:620a:2596:b0:75b:23a1:365d with SMTP id
 x22-20020a05620a259600b0075b23a1365dmr890428qko.30.1686121373945; Wed, 07 Jun
 2023 00:02:53 -0700 (PDT)
MIME-Version: 1.0
References: <20230605180404.130456-1-etemesicaleb@gmail.com>
 <468d6618-c8d5-485a-9052-dadf9befc6fb@gmail.com>
In-Reply-To: <468d6618-c8d5-485a-9052-dadf9befc6fb@gmail.com>
From: Caleb Etemesi <etemesicaleb@gmail.com>
Date: Wed, 7 Jun 2023 10:02:42 +0300
Message-ID: <CAF7=sGKXnos0LihhZqRw5=RhvvfJG9JEvgNXWoPa5WhPxnLxkA@mail.gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
X-Content-Filtered-By: Mailman/MimeDel 2.1.29
Subject: Re: [FFmpeg-devel] [PATCH] avcodec/jpeg2000htdec: Check for invalid
 magref length.
X-BeenThere: ffmpeg-devel@ffmpeg.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org>
List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe>
List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel>
List-Post: <mailto:ffmpeg-devel@ffmpeg.org>
List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help>
List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe>
Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: ffmpeg-devel-bounces@ffmpeg.org
Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org>
Archived-At: <https://master.gitmailbox.com/ffmpegdev/CAF7=sGKXnos0LihhZqRw5=RhvvfJG9JEvgNXWoPa5WhPxnLxkA@mail.gmail.com/>
List-Archive: <https://master.gitmailbox.com/ffmpegdev/>
List-Post: <mailto:ffmpegdev@gitmailbox.com>

will send updated patch with changes in a few

On Tue, 6 Jun 2023, 19:20 James Almer, <jamrial@gmail.com> wrote:

> On 6/5/2023 3:04 PM, etemesicaleb@gmail.com wrote:
> > From: caleb <etemesicaleb@gmail.com>
> >
> > ---
> >   libavcodec/jpeg2000htdec.c | 10 +++++++---
> >   1 file changed, 7 insertions(+), 3 deletions(-)
> >
> > diff --git a/libavcodec/jpeg2000htdec.c b/libavcodec/jpeg2000htdec.c
> > index 51cd96e0f1..474d671ee0 100644
> > --- a/libavcodec/jpeg2000htdec.c
> > +++ b/libavcodec/jpeg2000htdec.c
> > @@ -1101,8 +1101,8 @@ static void
> jpeg2000_decode_sigprop_segment(Jpeg2000Cblk *cblk, uint16_t width,
> >    * See procedure decodeSigPropMag at Rec. ITU-T T.814, 7.5.
> >   */
> >   static int
> > -jpeg2000_decode_magref_segment(Jpeg2000Cblk *cblk, uint16_t width,
> uint16_t block_height, uint8_t *magref_segment,
> > -                       uint32_t magref_length, uint8_t pLSB, int32_t
> *sample_buf, uint8_t *block_states)
> > +jpeg2000_decode_magref_segment(const Jpeg2000DecoderContext
> *s,Jpeg2000Cblk *cblk, uint16_t width, uint16_t block_height, uint8_t
> *magref_segment,
> > +                               uint32_t magref_length, uint8_t pLSB,
> int32_t *sample_buf, uint8_t *block_states)
>
> This could be split in three lines.
>
> >   {
> >
> >       StateVars mag_ref           = { 0 };
> > @@ -1111,6 +1111,10 @@ jpeg2000_decode_magref_segment(Jpeg2000Cblk
> *cblk, uint16_t width, uint16_t bloc
> >       uint16_t i_start            = 0;
> >       int32_t *sp;
> >
> > +    if (magref_length < 2){
> > +        av_log(s->avctx,AV_LOG_ERROR,"Invalid magnitude refinement
> length\n");
> > +        return AVERROR_INVALIDDATA;
> > +    }
>
> Why not add this check and log call before calling
> jpeg2000_decode_magref_segment()? That way you don't need to add
> Jpeg2000DecoderContext as a parameter to it.
>
> >       jpeg2000_init_mag_ref(&mag_ref, magref_length);
> >
> >       for (int n1 = 0; n1 < num_v_stripe; n1++) {
> > @@ -1261,7 +1265,7 @@ ff_jpeg2000_decode_htj2k(const
> Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c
> >                                   pLSB - 1, sample_buf, block_states);
> >
> >       if (cblk->npasses > 2)
> > -        if ((ret = jpeg2000_decode_magref_segment(cblk, width, height,
> Dref, Lref,
> > +        if ((ret = jpeg2000_decode_magref_segment(s,cblk, width,
> height, Dref, Lref,
> >                                             pLSB - 1, sample_buf,
> block_states)) < 0)
> >               goto free;
> >
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".