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 409BF4100A for ; Mon, 14 Mar 2022 17:08:42 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1E85A68B0AE; Mon, 14 Mar 2022 19:08:40 +0200 (EET) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 29B7468A7B8 for ; Mon, 14 Mar 2022 19:08:34 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 07902E6526 for ; Mon, 14 Mar 2022 18:08:34 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id K0L63lqaZHxc for ; Mon, 14 Mar 2022 18:08:32 +0100 (CET) Received: from iq (iq [217.27.212.140]) by iq.passwd.hu (Postfix) with ESMTPS id 97A52E67E1 for ; Mon, 14 Mar 2022 18:08:32 +0100 (CET) Date: Mon, 14 Mar 2022 18:08:32 +0100 (CET) From: Marton Balint To: FFmpeg development discussions and patches In-Reply-To: <20220314135819.GW2829255@pb2> Message-ID: <7e83992a-db22-601f-782b-96c2cfe54bd4@passwd.hu> References: <20220312235227.19626-1-michael@niedermayer.cc> <20220312235227.19626-3-michael@niedermayer.cc> <1e687354-29fa-6c18-2850-c1fe7da6bd42@passwd.hu> <20220314135819.GW2829255@pb2> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH 3/4] avformat/mxfdec: Check for avio_read() failure in mxf_read_strong_ref_array() 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Mon, 14 Mar 2022, Michael Niedermayer wrote: > On Sun, Mar 13, 2022 at 04:52:25PM +0100, Marton Balint wrote: >> >> >> On Sun, 13 Mar 2022, Michael Niedermayer wrote: >> >>> Signed-off-by: Michael Niedermayer >>> --- >>> libavformat/mxfdec.c | 8 +++++++- >>> 1 file changed, 7 insertions(+), 1 deletion(-) >>> >>> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c >>> index d7cdd22c8a..828fc0f9f1 100644 >>> --- a/libavformat/mxfdec.c >>> +++ b/libavformat/mxfdec.c >>> @@ -932,6 +932,7 @@ static int mxf_read_cryptographic_context(void *arg, AVIOContext *pb, int tag, i >>> >>> static int mxf_read_strong_ref_array(AVIOContext *pb, UID **refs, int *count) >>> { >>> + int64_t ret; >>> unsigned c = avio_rb32(pb); >>> >>> //avio_read() used int >>> @@ -946,7 +947,12 @@ static int mxf_read_strong_ref_array(AVIOContext *pb, UID **refs, int *count) >>> return AVERROR(ENOMEM); >>> } >>> avio_skip(pb, 4); /* useless size of objects, always 16 according to specs */ >>> - avio_read(pb, (uint8_t *)*refs, *count * sizeof(UID)); >>> + ret = avio_read(pb, (uint8_t *)*refs, *count * sizeof(UID)); >>> + if (ret != *count * sizeof(UID)) { >>> + *count = ret < 0 ? 0 : ret / sizeof(UID); >> > >> I suggest you hard fail if the read count is not the expected, do not >> silently ignore corrupt file. >> >> Regards, >> Marton >> >>> + return ret < 0 ? ret : AVERROR_INVALIDDATA; > > Does it not hard fail here ? Yeah, it does, sorry. This extra count calculation confused me... I'd just probably set it to 0 in case of a partial read, same as in case of an error, but fine either way I guess. Regards, Marton _______________________________________________ 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".