From patchwork Sat Jun 3 19:44:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 41967 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c51c:b0:10c:5e6f:955f with SMTP id gm28csp2116911pzb; Sat, 3 Jun 2023 12:44:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Yr8jRhUPLfwxAFIrS7ynHFVkb8B/2rlLX2qKb4pIq1tz8qjMVoSxtmudzUIt8ucUJaY5j X-Received: by 2002:a17:907:6e86:b0:965:ae3a:52c8 with SMTP id sh6-20020a1709076e8600b00965ae3a52c8mr2350558ejc.32.1685821489398; Sat, 03 Jun 2023 12:44:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685821489; cv=none; d=google.com; s=arc-20160816; b=Je+7ZP5FglstDwJPeIU9toiT0HXf4ar1BKcqeDE+pDrJhFxtjOf1b6UzGKyyZZ7FSU 24XPtdQ6TcMLsX93awAHDcjG93UuZhc6snVBAi2mVnBR544yMi91OwB6eqofHVIcr2WF ArfpHhq9hAyQJP+DVpRsyaTdZwYanPqlcY4a3LeO3+5M1/61TbJ1UHXpSH/7XG7sXAJr UBDEyjXpdkeyHHOuUAbvtRqcA/JhTxZ9XCGMBftcx3zts9pdwceApwD51gUvG37qH+gR vJasjKkxFiOdO4Z/zanRLjAx0V1yM4hkLZGY/+6in38IBjuZlys4icPr1ANTZg51s7GM ccdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:delivered-to; bh=vdBZOBoJ7kGKx9aOUtt8+PIXDkQL+ODQtTz5MkCk4Pk=; b=w/OyuojPMc1v/UfixQg625bPucZzdCZC0pqRi3ticcP7OkFq3PFAmuE24wNLPInQjh utflwjhO+zwKWtaaSfZrVAt6gaPofl/r1FgrLjLFbEohU0ogxJO/Cy3UTaXjjgnVdAc1 463RqYSK4DTM5LVQEjquZgMmynTQFbTYDJehlfv3oWqXubkIZIksCP548Nb+iX7Wovgu gkDkps5EYFdcd10YLHILiSK/CZslPEsZwnq0Do+fYUr0xqX0rB/I3PokmYVX1e4r/EiL xm8XWmQS4zEEEIoGYuqh/epx8BKDGykeGAz7txGDuSP9w1MYFw/HIU/cpzxIpzsa+LfB NCcg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ga36-20020a1709070c2400b0097463080c4bsi3395815ejc.525.2023.06.03.12.44.48; Sat, 03 Jun 2023 12:44:49 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6E69768BF89; Sat, 3 Jun 2023 22:44:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D841E68C130 for ; Sat, 3 Jun 2023 22:44:38 +0300 (EEST) X-GND-Sasl: michael@niedermayer.cc Received: by mail.gandi.net (Postfix) with ESMTPSA id 27D4B1C0002 for ; Sat, 3 Jun 2023 19:44:37 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sat, 3 Jun 2023 21:44:37 +0200 Message-Id: <20230603194437.23694-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH] avcodec: Ignoring errors is only possible before the input end 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: pU9dto369pok Fixes: out of array read Fixes: Ticket 10308 Signed-off-by: Michael Niedermayer --- libavcodec/h263dec.c | 2 +- libavcodec/mpeg4videodec.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index f4e7048a5f..68a618a7ed 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -281,7 +281,7 @@ static int decode_slice(MpegEncContext *s) ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR & part_mask); - if (s->avctx->err_recognition & AV_EF_IGNORE_ERR) + if ((s->avctx->err_recognition & AV_EF_IGNORE_ERR) && get_bits_left(&s->gb) > 0) continue; return AVERROR_INVALIDDATA; } diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index d456e5dd11..30aec5e529 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -1437,7 +1437,7 @@ static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block, if (SHOW_UBITS(re, &s->gb, 1) == 0) { av_log(s->avctx, AV_LOG_ERROR, "1. marker bit missing in 3. esc\n"); - if (!(s->avctx->err_recognition & AV_EF_IGNORE_ERR)) + if (!(s->avctx->err_recognition & AV_EF_IGNORE_ERR) || get_bits_left(&s->gb) <= 0) return AVERROR_INVALIDDATA; } SKIP_CACHE(re, &s->gb, 1); @@ -1448,7 +1448,7 @@ static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block, if (SHOW_UBITS(re, &s->gb, 1) == 0) { av_log(s->avctx, AV_LOG_ERROR, "2. marker bit missing in 3. esc\n"); - if (!(s->avctx->err_recognition & AV_EF_IGNORE_ERR)) + if (!(s->avctx->err_recognition & AV_EF_IGNORE_ERR) || get_bits_left(&s->gb) <= 0) return AVERROR_INVALIDDATA; }