* [FFmpeg-devel] [PATCH] av_format/whip: fix potential overflow (PR #20357)
@ 2025-08-28 0:05 Jack Lau via ffmpeg-devel
0 siblings, 0 replies; only message in thread
From: Jack Lau via ffmpeg-devel @ 2025-08-28 0:05 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Jack Lau
PR #20357 opened by Jack Lau (JackLau)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20357
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20357.patch
>From 7c533ae7404fb20a4513ef766e368300dfe3cc54 Mon Sep 17 00:00:00 2001
From: Jack Lau <jacklau1222@qq.com>
Date: Thu, 28 Aug 2025 07:22:04 +0800
Subject: [PATCH 1/2] avformat/whip: fix 8-bit overflow and map constraint_set
bits for H264
profile_iop is an 8-bit field. Previous code copied
AVCodecParameters::profile (which can contain bits
beyond 8 bits) into profile_iop, producing overflow
and wrong values.
This patch maps the constrained flags into the proper
profile_iop bits (constraint_set1/3)
Signed-off-by: Jack Lau <jacklau1222@qq.com>
---
libavformat/whip.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/libavformat/whip.c b/libavformat/whip.c
index 1fcf19aaa3..de8513aadf 100644
--- a/libavformat/whip.c
+++ b/libavformat/whip.c
@@ -562,7 +562,7 @@ static int parse_codec(AVFormatContext *s)
*/
static int generate_sdp_offer(AVFormatContext *s)
{
- int ret = 0, profile, level, profile_iop;
+ int ret = 0, profile, level, profile_iop = 0;
const char *acodec_name = NULL, *vcodec_name = NULL;
AVBPrint bp;
WHIPContext *whip = s->priv_data;
@@ -630,11 +630,12 @@ static int generate_sdp_offer(AVFormatContext *s)
}
if (whip->video_par) {
- profile_iop = profile = whip->video_par->profile;
+ profile = whip->video_par->profile;
level = whip->video_par->level;
if (whip->video_par->codec_id == AV_CODEC_ID_H264) {
vcodec_name = "H264";
- profile_iop &= AV_PROFILE_H264_CONSTRAINED;
+ profile_iop |= profile & AV_PROFILE_H264_CONSTRAINED ? 1 << 6 : 0;
+ profile_iop |= profile & AV_PROFILE_H264_INTRA ? 1 << 4 : 0;
profile &= (~AV_PROFILE_H264_CONSTRAINED);
}
--
2.49.1
>From df611cb6101d136a300f6ee17a57d7a966f40b80 Mon Sep 17 00:00:00 2001
From: Jack Lau <jacklau1222@qq.com>
Date: Thu, 28 Aug 2025 07:40:40 +0800
Subject: [PATCH 2/2] avformat/whip: fix potential 8bit overflow for
profile_idc
The profile contains profile_idc and constraint_set*_flag,
throws away high 8 bit flags and then we get profile_idc.
Signed-off-by: Jack Lau <jacklau1222@qq.com>
---
libavformat/whip.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/libavformat/whip.c b/libavformat/whip.c
index de8513aadf..0089c17b9a 100644
--- a/libavformat/whip.c
+++ b/libavformat/whip.c
@@ -562,7 +562,7 @@ static int parse_codec(AVFormatContext *s)
*/
static int generate_sdp_offer(AVFormatContext *s)
{
- int ret = 0, profile, level, profile_iop = 0;
+ int ret = 0, profile_idc = 0, level, profile_iop = 0;
const char *acodec_name = NULL, *vcodec_name = NULL;
AVBPrint bp;
WHIPContext *whip = s->priv_data;
@@ -630,13 +630,12 @@ static int generate_sdp_offer(AVFormatContext *s)
}
if (whip->video_par) {
- profile = whip->video_par->profile;
level = whip->video_par->level;
if (whip->video_par->codec_id == AV_CODEC_ID_H264) {
vcodec_name = "H264";
- profile_iop |= profile & AV_PROFILE_H264_CONSTRAINED ? 1 << 6 : 0;
- profile_iop |= profile & AV_PROFILE_H264_INTRA ? 1 << 4 : 0;
- profile &= (~AV_PROFILE_H264_CONSTRAINED);
+ profile_iop |= whip->video_par->profile & AV_PROFILE_H264_CONSTRAINED ? 1 << 6 : 0;
+ profile_iop |= whip->video_par->profile & AV_PROFILE_H264_INTRA ? 1 << 4 : 0;
+ profile_idc = whip->video_par->profile & 0x00ff;
}
av_bprintf(&bp, ""
@@ -662,7 +661,7 @@ static int generate_sdp_offer(AVFormatContext *s)
whip->video_payload_type,
vcodec_name,
whip->video_payload_type,
- profile,
+ profile_idc,
profile_iop,
level,
whip->video_ssrc,
--
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-08-28 0:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-28 0:05 [FFmpeg-devel] [PATCH] av_format/whip: fix potential overflow (PR #20357) 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