From patchwork Tue Sep 24 22:03:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 15267 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id DCD1E449BE7 for ; Wed, 25 Sep 2019 01:03:45 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C870768A28B; Wed, 25 Sep 2019 01:03:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8FBD6689DCF for ; Wed, 25 Sep 2019 01:03:43 +0300 (EEST) Received: by mail-wr1-f68.google.com with SMTP id v8so3804422wrt.2 for ; Tue, 24 Sep 2019 15:03:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+100awYnlUisL9uH7wQgEueLsTBsLN5FjJym3+Nh6mw=; b=NI2eviFNuEAeCeceBJfm2iJmoqML/OeYmCcVix0Ik031aopp7ydk/O9qH9qQ4Jfh88 c7IzZmrEzyhwIJPawwTIEJYzRtTcaRYSkP59BKBj80V0j2Ie0rzqAD2FActXEvRCqX6Y nFgMVHlxzMlWzH/jY5RIBbD+0fqScwgtWxLgLKOmd3qBoTV6i9gigmRId0qIW0uqQfkW 1tQ8eFvvrp46zOwnJZodVJfbaUJlJINiwnnCYgaTPiFHw3Dv8qYG0r4W8ViZKNvc5XAy MqkdR8SIXdjGtrop3OJZ0mOb6OnlunJPm8yMx7bEA6hsm3c/yiNPoldIr5DIzP6BoTc4 g1lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+100awYnlUisL9uH7wQgEueLsTBsLN5FjJym3+Nh6mw=; b=q1f1DfroGBNSKI2rSY06MhtIdCwtlYV7SNl97UZLRM57QDOZO995Y0tZW2gSmrezKl HzELvpaeyQa004gt2zM7JnM4B5x0Njl/Y0m5SdRz6pzEAU10xMTXUeRrJHPedLWUB+BN G7FvOmF3Hodzv+E22dcj4YQy61Lhc4p07klBI/7ibGNKgcJv8KCaVOgF9T3xKFEqhZfL mGX1QcbpGosj9BwXVbcPl5neTxQcX5jMsB6qz9biEexoi39I/igvzOC/Sm8ITk8HN5QG rt9hu3qbJvErl6utM7LoiIc2JT9/52raUuNzHmBwlJ1rRXbLfUqZRXJdAgTY5iYHJnpQ GGpA== X-Gm-Message-State: APjAAAWOVhSbrBlFH/dc998RewQeRsMxVeuk5ke5eO9lYU3eZLG92oni GXIbUQl/wH9zNV8/JhSOFJg1w3j3 X-Google-Smtp-Source: APXvYqwHVUbZud2p/LKjRukPjwCXXHJfXaAVRrV57N3+IO2HlNpwostiGPSYN7VYLY8Jr4US5KNzKQ== X-Received: by 2002:adf:f60e:: with SMTP id t14mr420461wrp.279.1569362622370; Tue, 24 Sep 2019 15:03:42 -0700 (PDT) Received: from sblaptop.fritz.box ([188.192.248.87]) by smtp.gmail.com with ESMTPSA id l1sm3023808wrb.1.2019.09.24.15.03.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2019 15:03:41 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 25 Sep 2019 00:03:04 +0200 Message-Id: <20190924220310.31157-10-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190924220310.31157-1-andreas.rheinhardt@gmail.com> References: <20190924220310.31157-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 09/15] avcodec/ffv1enc: Fix out-of-bounds-array access X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" libavcodec/ffv1enc.c accessed an array of uint8_t [32] via array[0][j] in order to loop over all the uint8_t in this array of arrays. Of course this implied an out-of-bounds access for array[0] and UBSan complained about this. So perform the access via an ordinary pointer to uint8_t. This affected the FATE-tests vsynth1-ffv1, vsynth1-ffv1-v3-yuv420p, vsynth1-ffv1-v3-yuv422p10, vsynth1-ffv1-v3-yuv444p16, vsynth1-ffv1-v3-bgr0, vsynth1-ffv1-ffv1-v3-rgb48 as well as the corresponding vsynth2-*, vsynth3-* and the vsynth_lena-* tests. Signed-off-by: Andreas Rheinhardt --- libavcodec/ffv1enc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index 1bf9663053..5eb439135c 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -429,8 +429,9 @@ static int write_extradata(FFV1Context *f) for (i = 0; i < f->quant_table_count; i++) { if (f->initial_states[i]) { + uint8_t *initial_state = &f->initial_states[i][0][0]; for (j = 0; j < f->context_count[i] * CONTEXT_SIZE; j++) - if (f->initial_states[i][0][j] != 128) + if (initial_state[j] != 128) break; } else { j = f->context_count[i] * CONTEXT_SIZE;