From patchwork Tue Sep 1 15:03:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derek Buitenhuis X-Patchwork-Id: 22048 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 02391449BE3 for ; Tue, 1 Sep 2020 18:09:09 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D4F5868AC37; Tue, 1 Sep 2020 18:09:08 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1B11168A585 for ; Tue, 1 Sep 2020 18:09:02 +0300 (EEST) Received: by mail-wm1-f44.google.com with SMTP id c19so1166675wmd.1 for ; Tue, 01 Sep 2020 08:09:02 -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=ba1u49SX4tgGEOmHAF0LhCWx0HByqN1MWyfAifASitQ=; b=i2GIeZ9URZURoQhyVGqvjsHzzoM35EqZLHR0ShtF+yMFVPshz9Ck0f7fuKohhbzEXi 5KwDyyEeSxl4Rn+Hl7AoM0f2rRdHPnpodWkaoJP0xtwjj+xUv9X2CCPtvbGJt4m0s+LU ZQkl7tn2lyuSMFXyNzojMrBsw2LnciW5iq4ZqQ4JJhK/UTUEFTwJy/iLpavMKACvCAy5 G8MuHQoftKhIT25bdz9C/U8Kq9h2u5ggAMQV9r1a8WqPPeoHYBT+d1qkGGk2jTjJhPNc /bT+9b/77wb2xiNXpqChc6QVqXEll/+OH0baENuKo2J5MyHnEEyYomdB9BfG41N51MGH hFCA== 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=ba1u49SX4tgGEOmHAF0LhCWx0HByqN1MWyfAifASitQ=; b=FEI7qustY0mdP+IoMhkkHQ2c1vJuYrr9Pdie5clN3d+all7oQfBqc0YKGRYFnhjeUa w/OEP38OFH8JJGLP75hX3b5xXs8t1kMf1Xwm2bUMalkmmAcAnEvItw5LiDo6YH9ds6FB C1G/HVeIosVMHI3oZaOeCJcCmraWKhXZJoI343vGUgpB58UqIQgbI8XKHVD+1lyfMAXv 94ZmxWLOaqkDDlNgo7dB2pEEOOzKKlev/OOFIfpP6Du9zn8GND1P2DwuYlsJj8BiGtNH m7c33DFGwiNPDfX18NsEE8TOQ82TcFDHg356w/wVUAJPVeElkHWySHswbxFm3Rd+I8Et 18cw== X-Gm-Message-State: AOAM530F4ZYJgbO8IEyZdfHj0eGsF4KaISh941V69K+s6GMmkO77Wa2m o3LTrEoP2fiSj4taiHnbTOT5RVPgcO8= X-Google-Smtp-Source: ABdhPJybXTfUXnok4JWcAayEK8gzWAy11Crk/fJJZHRqbXM/fyVGzVgd4pTuV4+RWF/qK+yl1l/IUw== X-Received: by 2002:a05:600c:2183:: with SMTP id e3mr2311228wme.49.1598972631022; Tue, 01 Sep 2020 08:03:51 -0700 (PDT) Received: from localhost.localdomain ([81.2.169.31]) by smtp.gmail.com with ESMTPSA id l18sm2655252wrm.52.2020.09.01.08.03.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 08:03:49 -0700 (PDT) From: Derek Buitenhuis To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Sep 2020 16:03:35 +0100 Message-Id: <20200901150335.103855-4-derek.buitenhuis@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901150335.103855-1-derek.buitenhuis@gmail.com> References: <20200901150335.103855-1-derek.buitenhuis@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/4] avformat/mov: Stash mfra size if we're reading it anyway 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: dalecurtis@chromium.org Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This also changes a check for mfra_size from < 0 to == 0, since it was always wrong, as avio_rb32 returns an unsigned integer. Signed-off-by: Derek Buitenhuis --- libavformat/mov.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index e33031f158..e901eb527f 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -7499,22 +7499,22 @@ static int mov_read_mfra(MOVContext *c, AVIOContext *f) int64_t stream_size = avio_size(f); int64_t original_pos = avio_tell(f); int64_t seek_ret; - int32_t mfra_size; int ret = -1; if ((seek_ret = avio_seek(f, stream_size - 4, SEEK_SET)) < 0) { ret = seek_ret; goto fail; } - mfra_size = avio_rb32(f); - if (mfra_size < 0 || mfra_size > stream_size) { + c->mfra_size = avio_rb32(f); + c->have_read_mfra_size = 1; + if (c->mfra_size == 0 || c->mfra_size > stream_size) { av_log(c->fc, AV_LOG_DEBUG, "doesn't look like mfra (unreasonable size)\n"); goto fail; } - if ((seek_ret = avio_seek(f, -mfra_size, SEEK_CUR)) < 0) { + if ((seek_ret = avio_seek(f, -c->mfra_size, SEEK_CUR)) < 0) { ret = seek_ret; goto fail; } - if (avio_rb32(f) != mfra_size) { + if (avio_rb32(f) != c->mfra_size) { av_log(c->fc, AV_LOG_DEBUG, "doesn't look like mfra (size mismatch)\n"); goto fail; }