From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 4A7D8460C3 for ; Mon, 5 Jun 2023 18:04:44 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7B38068C42A; Mon, 5 Jun 2023 21:04:41 +0300 (EEST) Received: from mail-vk1-f171.google.com (mail-vk1-f171.google.com [209.85.221.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B645068C2B1 for ; Mon, 5 Jun 2023 21:04:34 +0300 (EEST) Received: by mail-vk1-f171.google.com with SMTP id 71dfb90a1353d-465db156268so265084e0c.3 for ; Mon, 05 Jun 2023 11:04:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685988273; x=1688580273; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=gZSRZX/ZYoC+FBvj1dJoPqtXuSm+lnjFsEH48dN1qtE=; b=If380EJwrK/gHwEZtVGQ8cf3jxgode9XVpVDrlCOPQGiape2tt3yFUfFPCyhAWftyr NqEj1812/9tu7DB8ohAmxPx2jTmdR/eTUHIn6/3umD0WX7NpRO3nX7VOEAfuYp+q9QWq ByaVybuA1XAZhszTK7uVBveAUmsXYDUbXZ1ZHzidiA4txfuj/eBQnZTniBo48qPCkltL bETKus1hRMFLcgXWYwTbTowEC823wyTahdXc5wYkwN3pOXngqAIp+AARpvvwLQklywlw YNNudky5TBhtg7oIwA6z+LjTHLsiVrmzj1HwOFCg+jnpR90Y/78VOD+rznu5PgaheRTu cs0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685988273; x=1688580273; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gZSRZX/ZYoC+FBvj1dJoPqtXuSm+lnjFsEH48dN1qtE=; b=XIm/hAHaB57mn6Zl3qgE2B9TA/tJ65+fkT+Ny60KZfiqmMGpjcxeiY+AB8hgzSJXW2 9PmEDRhlkvg+Z/pq1dSc16bjhA2g2wrHWYIAi8AXhO90VO1q3/PN5qP7UoDnF0tVnbpB JaqdNlF0odhwu8gX1qzJHv1kLf2wydDhcFWPonvRC2wDujJON6EaDN0Vbaosp9gXIQ2i PsjIhq9buRss6MhnmzKCNXsa2uPPKQr/5bQQE0mS5uOJ4tUen7kgrGMshKclEsR4dqDy S0nwcKv12a7ogb2DOudMIBc6iLtCUpMDoGQpcZTaBOTWzBdW0h0Ly1vr4r0zzkRuRps0 6TtA== X-Gm-Message-State: AC+VfDxBIq38kHURJNmIDpZc6Jh/7AExEg9dVKkDum7xSUrz4eBmQPLy nYC1QFNb3bXw5o5yYvMVWg63GfFJuSM9HA== X-Google-Smtp-Source: ACHHUZ4Mn0lGq+oWbaaJgBKkwea+ZsUAvDWi4h3OkmleW1jy8tAEe0gfBjaZVQAd7OrWyYLz00WFyg== X-Received: by 2002:a67:fa0a:0:b0:426:20a8:a5b0 with SMTP id i10-20020a67fa0a000000b0042620a8a5b0mr565681vsq.13.1685988272839; Mon, 05 Jun 2023 11:04:32 -0700 (PDT) Received: from localhost.localdomain ([41.80.118.92]) by smtp.gmail.com with ESMTPSA id t23-20020ab04ad7000000b00786fd01f05bsm1506421uae.24.2023.06.05.11.04.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jun 2023 11:04:32 -0700 (PDT) From: etemesicaleb@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Mon, 5 Jun 2023 21:04:04 +0300 Message-Id: <20230605180404.130456-1-etemesicaleb@gmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Subject: [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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: caleb , pal@sandflow.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: caleb --- 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) { 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; + } 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; -- 2.40.1 _______________________________________________ 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".