Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avformat/amr: add P bits check to avoid mis-detects (PR #21176)
@ 2025-12-12  7:03 Jack Lau via ffmpeg-devel
  0 siblings, 0 replies; only message in thread
From: Jack Lau via ffmpeg-devel @ 2025-12-12  7:03 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Jack Lau

PR #21176 opened by Jack Lau (JackLau)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21176
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21176.patch

Fix #21056

Refer to RFC 3267 Section 4.4.2:

A ToC entry takes the following format in octet-aligned mode:

 0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+
|F|  FT   |Q|P|P|
+-+-+-+-+-+-+-+-+

P bits: padding bits, MUST be set to zero.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>


>From 95a39927b24e649019fdaf640dc7dd45ea1161e9 Mon Sep 17 00:00:00 2001
From: Jack Lau <jacklau1222gm@gmail.com>
Date: Fri, 12 Dec 2025 14:52:58 +0800
Subject: [PATCH] avformat/amr: add P bits check to avoid mis-detects

Fix #21056

Refer to RFC 3267 Section 4.4.2:

A ToC entry takes the following format in octet-aligned mode:

 0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+
|F|  FT   |Q|P|P|
+-+-+-+-+-+-+-+-+

P bits: padding bits, MUST be set to zero.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
---
 libavformat/amr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/amr.c b/libavformat/amr.c
index 0db0a8d26a..9cc61baf55 100644
--- a/libavformat/amr.c
+++ b/libavformat/amr.c
@@ -144,7 +144,7 @@ static int amrnb_probe(const AVProbeData *p)
 
     while (i < p->buf_size) {
         mode = b[i] >> 3 & 0x0F;
-        if (mode < 9 && (b[i] & 0x4) == 0x4) {
+        if (mode < 9 && (b[i] & 0x4) == 0x4 && (b[i] & 0x03) == 0) {
             int last = b[i];
             int size = amrnb_packed_size[mode];
             while (size--) {
@@ -201,7 +201,7 @@ static int amrwb_probe(const AVProbeData *p)
 
     while (i < p->buf_size) {
         mode = b[i] >> 3 & 0x0F;
-        if (mode < 10 && (b[i] & 0x4) == 0x4) {
+        if (mode < 10 && (b[i] & 0x4) == 0x4 && (b[i] & 0x03) == 0) {
             int last = b[i];
             int size = amrwb_packed_size[mode];
             while (size--) {
-- 
2.49.1

_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-12-12  7:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-12  7:03 [FFmpeg-devel] [PATCH] avformat/amr: add P bits check to avoid mis-detects (PR #21176) Jack Lau via ffmpeg-devel

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