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 198C74096E for ; Tue, 1 Feb 2022 21:21:24 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 10D4268AFB1; Tue, 1 Feb 2022 23:21:15 +0200 (EET) Received: from mail-qv1-f52.google.com (mail-qv1-f52.google.com [209.85.219.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 860D6689CFC for ; Tue, 1 Feb 2022 23:21:08 +0200 (EET) Received: by mail-qv1-f52.google.com with SMTP id i19so17199361qvx.12 for ; Tue, 01 Feb 2022 13:21:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9dy4aYoVFlHLEy5HO7CVsCAQrO5cMvHaBQi63n/yq/0=; b=KKmikr379ilfHj+xWFiyDFiPX1YLBYmrek2bIPwT81hU3lEX5NXy49YogqZtf0ybnd 1VXZj57eTrV7o9Vo6kJIJEYbRR2QxpSjFf3VEq1DBcvv8AyHISz4iMUy8WgiaKIA8PqJ OoIQlp0wIiDtfYmM/py+JmiOqwAaPBnVoGwjqp5sPIb4YQDNrpFxSz6xaR5cvXTK89Zp 8FupfMhTN3/Mx4VATy+5zdhJ6SM0hRi68XmXw/JGlV+fs/QzoHNGp9WZfX4K6bMNFwu3 WdaO7ITXM4rd16Oj2W1hDwzoMbB2146LEZr6UGis5siBKaFKZepFkAOuUITXVljuzQgy DsgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9dy4aYoVFlHLEy5HO7CVsCAQrO5cMvHaBQi63n/yq/0=; b=fzpmy4UUUIsve/SCVLCDfnIzgcPd8vTNMb1SElINKkiHIk3Kq49Juq9AL6l76s5bWm JpxyUstFmzknpUBwAsHJzSr96fLuNz1B9UCGyWLRku1IRaTc1EQRvFGIAPzznzW9uRpt xuKPseTH8y+y+wv/oyliSfMJ4LXm6v1VFRlm9n38wTlXKJBTKVSf2zc86e/bufBw2XTy 6vseR4aVOZHLB+YYAtIbChQkL1wx6nwZbqyT0CLRwgjXpUkvulhb3cMGxGk+zmx6RoCk B28g8EM5bZbtGPJqIA4+KnRCkKBUL4VSqXd4GfB8vWTQ9muAMph2YSaDqN9ZBeMnRG/M 6PLA== X-Gm-Message-State: AOAM533ygbxD0qN0sW9KMf39WBav+1qdfoLpmIjOQjplBxdvUuOJiIsd g8OQ5VHZhIQivS6BXub+6X7hBbVy59lp4A== X-Google-Smtp-Source: ABdhPJyN4WUxv8WYnjE+lswtJN3+5qyI/OXK+oy3pkgF6cPeMdX4+i1nM0QNBCvTAIoWG/JqTFFd9Q== X-Received: by 2002:a05:6214:224b:: with SMTP id c11mr23793174qvc.114.1643750466837; Tue, 01 Feb 2022 13:21:06 -0800 (PST) Received: from localhost.localdomain ([151.200.235.219]) by smtp.gmail.com with ESMTPSA id ay18sm2928225qkb.8.2022.02.01.13.21.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 13:21:06 -0800 (PST) From: Scott Theisen To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 16:20:49 -0500 Message-Id: <20220201212056.29712-2-scott.the.elm@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220201212056.29712-1-scott.the.elm@gmail.com> References: <20220201212056.29712-1-scott.the.elm@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/8] avpriv_find_start_code(): readability enhancement part 1 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: Scott Theisen 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: No functional change. --- libavcodec/utils.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libavcodec/utils.c b/libavcodec/utils.c index b19befef21..cb4437edc2 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -967,10 +967,14 @@ const uint8_t *avpriv_find_start_code(const uint8_t *av_restrict p, } } - p = FFMIN(p, end) - 4; - *state = AV_RB32(p); + if (p > end) + p = end; + // this will cause the last 4 bytes before end to be read, + // i.e. no out of bounds memory access occurs - return p + 4; + *state = AV_RB32(p - 4); // read the previous 4 bytes + + return p; } AVCPBProperties *av_cpb_properties_alloc(size_t *size) -- 2.32.0 _______________________________________________ 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".