From: Anton Khirnov <anton@khirnov.net>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH] avcodec/dvdsub_parser: Fix length check for short packets
Date: Sat, 12 Nov 2022 14:49:33 +0100
Message-ID: <166826097339.20155.16301092167336471699@lain.khirnov.net> (raw)
In-Reply-To: <20220930142009.5862-1-aidanmacdonald.0x0@gmail.com>
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 <aidanmacdonald.0x0@gmail.com>
> ---
> 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".
prev parent reply other threads:[~2022-11-12 13:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-30 14:20 Aidan MacDonald
2022-11-12 13:49 ` Anton Khirnov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=166826097339.20155.16301092167336471699@lain.khirnov.net \
--to=anton@khirnov.net \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git