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 B08D0410B3 for ; Sat, 12 Nov 2022 13:49:48 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 12E1568B7D4; Sat, 12 Nov 2022 15:49:45 +0200 (EET) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AC6EB68B50E for ; Sat, 12 Nov 2022 15:49:38 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 57379240499 for ; Sat, 12 Nov 2022 14:49:37 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id XMFxWiszo293 for ; Sat, 12 Nov 2022 14:49:36 +0100 (CET) Received: from lain.khirnov.net (lain.khirnov.net [IPv6:2001:67c:1138:4306::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "lain.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 5C2362400F5 for ; Sat, 12 Nov 2022 14:49:36 +0100 (CET) Received: by lain.khirnov.net (Postfix, from userid 1000) id 6A44F1601B2; Sat, 12 Nov 2022 14:49:33 +0100 (CET) From: Anton Khirnov To: FFmpeg development discussions and patches In-Reply-To: <20220930142009.5862-1-aidanmacdonald.0x0@gmail.com> References: <20220930142009.5862-1-aidanmacdonald.0x0@gmail.com> Mail-Followup-To: FFmpeg development discussions and patches Date: Sat, 12 Nov 2022 14:49:33 +0100 Message-ID: <166826097339.20155.16301092167336471699@lain.khirnov.net> User-Agent: alot/0.8.1 MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH] avcodec/dvdsub_parser: Fix length check for short packets 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Quoting Aidan MacDonald (2022-09-30 16:20:09) > The DVD subtitle parser handles two types of packets: "normal" > packets with a 16-bit length, and HD-DVD packets that set the > 16-bit length to 0 and encode a 32-bit length in the next four > bytes. This implies that HD-DVD packets are at least six bytes > long, but the code didn't actually verify this. > > The faulty length check results in an out of bounds read for > zero-length "normal" packets that occur in the input, which are > only 2 bytes long, but get misinterpreted as an HD-DVD packet. > When this happens the parser reads packet_len from beyond the > end of the input buffer. The subtitle stream is not correctly > decoded after this point due to the garbage packet_len. > > Fixing this is pretty simple: fix the length check so packets > less than 6 bytes long will not be mistakenly parsed as HD-DVD > packets. > > Signed-off-by: Aidan MacDonald > --- > libavcodec/dvdsub_parser.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavcodec/dvdsub_parser.c b/libavcodec/dvdsub_parser.c > index 44738a73d6..8871b6a383 100644 > --- a/libavcodec/dvdsub_parser.c > +++ b/libavcodec/dvdsub_parser.c > @@ -43,7 +43,7 @@ static int dvdsub_parse(AVCodecParserContext *s, > *poutbuf_size = buf_size; > > if (pc->packet_index == 0) { > - if (buf_size < 2 || AV_RB16(buf) && buf_size < 6) { > + if (buf_size < 2 || (AV_RB16(buf) == 0 && buf_size < 6)) { Looks good, will push. -- Anton Khirnov _______________________________________________ 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".