From patchwork Wed May 10 21:58:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 41574 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dca6:b0:f3:34fa:f187 with SMTP id ky38csp4169972pzb; Wed, 10 May 2023 14:58:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6mC0yAUsi/MDYIUXcNVBP9kL8ermsKNNnR8pKDbGgKAadPjuLvKGgDALIDIbGgx3rywlub X-Received: by 2002:a05:6402:389:b0:50b:f72f:adf8 with SMTP id o9-20020a056402038900b0050bf72fadf8mr15929913edv.21.1683755923403; Wed, 10 May 2023 14:58:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683755923; cv=none; d=google.com; s=arc-20160816; b=meAyysRY3lpL80dBl9nW9I1wSX8HWnTucXzH/DkfxeTKrv8HTSDay9N8lfjOD0GWun zIEQPWHtU2+NkA8aSbtpUG3G3t4zVbjJ9z+dSQgAVEXYAoBi/wt/cglPx9hXfbOOjwyz itsbiEp58nD+RxZePYlqWCzdL8lJfilTf8WzUbABxgV3lsaC53FHFhcnVL4GMep2+a6L vDc26uFV5fJasetPdA+DQlcB3wqvUmr0Sq0Q302gSYeXYVPoR8MTEiXPDyYxx9r6LILI sf2QgCi0bLqdmdjUijhMaLt/xMpiHyDRkx6j34lYaPz9i6YfJs/79iw5GRdXoSm3WHHY kV6A== 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 :delivered-to; bh=Oo5PAeR2BXDf5Og+SE1CYZ50fnEBt7AExPEW3W+iwOI=; b=LgBJh5kN2YNfhNZ5wgc5GgzkWa8Y79U+/aJCrdRlyCnhhsGGA+wKsEY9KtoTr74Gbv iq2yku6HLsLFAJThYM6FVaqpW/xw9IevGfArvskgCDedan+AekqW7gZwEcU3o95ZWyrT I/3Vo03ht91Tvs44meONrWdWfwvgBQUIqzwbxGRoLDyVR8emBWb/DullxL8or+lHrC0b gaB7RaZFTi0d8ihrNJeJAQ2zqdDX+oRrM/laZ9H6dQyjkhrAoA5pJg1bZMNzsZQRV/O7 At10oKVdcHspOivsC30bLVxro+hBFMnudzmMWc+MV7iUuMPmQz0APkxVl0flwGt1xguF oR5A== 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 g16-20020a056402115000b0050bc014786esi3661409edw.33.2023.05.10.14.58.42; Wed, 10 May 2023 14:58:43 -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 7D22E68C123; Thu, 11 May 2023 00:58:40 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 02CED68BE02 for ; Thu, 11 May 2023 00:58:33 +0300 (EEST) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 40882E0003 for ; Wed, 10 May 2023 21:58:33 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Wed, 10 May 2023 23:58:31 +0200 Message-Id: <20230510215832.1001-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] avformat/format: Stop reading data at EOF during probing 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: Xz1OHGROyu/x Issue found by: Сергей Колесников Signed-off-by: Michael Niedermayer --- libavformat/format.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/format.c b/libavformat/format.c index 76f25ab5a6..52b814e67d 100644 --- a/libavformat/format.c +++ b/libavformat/format.c @@ -231,6 +231,7 @@ int av_probe_input_buffer2(AVIOContext *pb, const AVInputFormat **fmt, int ret = 0, probe_size, buf_offset = 0; int score = 0; int ret2; + int eof = 0; if (!max_probe_size) max_probe_size = PROBE_BUF_MAX; @@ -254,7 +255,7 @@ int av_probe_input_buffer2(AVIOContext *pb, const AVInputFormat **fmt, } } - for (probe_size = PROBE_BUF_MIN; probe_size <= max_probe_size && !*fmt; + for (probe_size = PROBE_BUF_MIN; probe_size <= max_probe_size && !*fmt && !eof; probe_size = FFMIN(probe_size << 1, FFMAX(max_probe_size, probe_size + 1))) { score = probe_size < max_probe_size ? AVPROBE_SCORE_RETRY : 0; @@ -270,6 +271,7 @@ int av_probe_input_buffer2(AVIOContext *pb, const AVInputFormat **fmt, score = 0; ret = 0; /* error was end of file, nothing read */ + eof = 1; } buf_offset += ret; if (buf_offset < offset)