From patchwork Fri Jun 7 00:32:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 49633 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:c209:0:b0:460:55fa:d5ed with SMTP id d9csp715659vqo; Thu, 6 Jun 2024 17:32:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXkdmuyQhF3AsEl8m1QEFha1ko1Oqoey/dj24zTg+1FwFIeRGFUZw/AKiXlsUCT5co18W99V/307suuKbVQ7GVpToCgC7V2hiacKw== X-Google-Smtp-Source: AGHT+IF8fXJ8BZHgXhh71uzfRoCfAMrp3LWMthv5/mCmCrhlcwuEjs9CT0QxqHTZiZ7s9Miqsblp X-Received: by 2002:a17:906:aec4:b0:a6c:84e3:fda3 with SMTP id a640c23a62f3a-a6cdb9dc88fmr59345866b.5.1717720348262; Thu, 06 Jun 2024 17:32:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717720348; cv=none; d=google.com; s=arc-20160816; b=BoCZFtfzMmnKQXvDLyZWgYSJXGfOlJKVBskkYiwNNpTNOsgdbnHc7Ux4eRJFxqAjur ZYhAh7GM1U4myndu2o+fxHNuPpS473nYW+J3+BMDrWYxfGPjZ4iuLLLvQBOfsaQbZO8C F0k2oLEfxxN2WCrMIJYn+muaAvgCj+m9F7/ZI8w7xn0iMTHLPCVCsIpdxE57TNtB0xAc Gkl4ggCN0HUJCulDRlV5YUWi9f1YiGRR22tz5zb6wnsaNPRx+tqMRClHxMRXs59byvQx o+Z9iijX/uNcF0Xfn006l6uqWwZ9rx3ptnlnHaXhlDzScXSDBbn9QwD52AO4rFlKg7Ud jG0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=MXz/18WuOMLKLzzdf6O2RK7NC5irV0fk1VfT6TGJqE8=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=ExFki+ESDyRmoH27Br9ZcZlCJqVVB/rDbuj2AcsdADwbbCg+utzlr9xuAIvVh5AbqN jsk7BRZinPLHF4vbFmvYOHk5abVUINAP47sWm0oKVoEYANNhaqQrc7hJKfWyQomePEVs zeYmlPTgmgIdKgXp9wMdqbeBcUifvtLzoVmfDehAL0PsLdmcTG+qZMS+/wNglGcDiaXa 76SAFybJFmok2ZadEIpeSeYZmquBYIIR70dY+8RhFCqR+SK0IMbm8cZRJ4zvbMeahk9a kTAiIHz8UNggev4/jZ3V9aEzco1GHzr0ov7UcioYxA0nRzKZUxw4JKq/Qt0HLd41jCN4 LOfg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@niedermayer.cc header.s=gm1 header.b=jAqaFloZ; 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 a640c23a62f3a-a6c806db5cdsi120021466b.364.2024.06.06.17.32.27; Thu, 06 Jun 2024 17:32:28 -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; dkim=neutral (body hash did not verify) header.i=@niedermayer.cc header.s=gm1 header.b=jAqaFloZ; 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 BC09968D72A; Fri, 7 Jun 2024 03:32:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7238C68D728 for ; Fri, 7 Jun 2024 03:32:17 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 9EF3760002 for ; Fri, 7 Jun 2024 00:32:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1717720336; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=XCiGjq20S3ILGYi7Dji5bqwkfRoWB27YJYJZ/6+YBZA=; b=jAqaFloZLmtNm/o0DxgXN1ZuPei5ohE3TNnwy7cWjy8sFhwuH5dDtrN+87OfoNUB3xCMZD Hy6iOraTQO7NvofE/p9TtG/guhWHl2rDeBMjXwoI7lq2rEoVnOrOckKL8w76Xu2hvmWXHL 8FMI4fnArHrUAFIXgESBPVyvkDQPZnJwmlJRnuUnwjVBv/37c93oxukgG9LWsJJ2+DAFfs LwYyXQCYvaU2JVtsP7MLvV8CkeNWz+AzQrh8YlOgUwAOHUFZk25gXHTJlio8JBooANv9FE 8FlWYIPKPvdGSo6ftFYVzZjS4AdHsmSMcsGP7Bv955eQnU42kgYYtrqROdjaEw== From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 7 Jun 2024 02:32:11 +0200 Message-ID: <20240607003215.1723906-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 1/5] avformat/mov: Check requested_sample before using it 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: T6IgQosu4AAZ I am not sure the case described by coverity is possible but its more robust checking the argument first Fixes: CID1598441 Improper use of negative value Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer --- libavformat/mov.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 9016cd5ad08..f571b0468ee 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -10161,7 +10161,7 @@ static int mov_seek_stream(AVFormatContext *s, AVStream *st, int64_t timestamp, // If we've reached a different sample trying to find a good pts to // seek to, give up searching because we'll end up seeking back to // sample 0 on every seek. - if (!can_seek_to_key_sample(st, requested_sample, next_ts) && sample != requested_sample) + if (sample != requested_sample && !can_seek_to_key_sample(st, requested_sample, next_ts)) break; timestamp = next_ts;