Skip to content

Commit 8ad555b

Browse files
fippoWebRTC LUCI CQ
authored andcommitted
[merge to M97] sdp: reject large number of channels
the maximum used in practice is multiopus with 6 or 8 channels. 24 is the maximum number of channels supported in the audio decoder. BUG=chromium:1265806 (cherry picked from commit d58ac5a) No-Try: True Change-Id: Iba8e3185a1f235b846fed9c154e66fb3983664ed Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/238980 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Philipp Hancke <phancke@nvidia.com> Cr-Original-Commit-Position: refs/heads/main@{#35440} Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/240180 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/branch-heads/4692@{webrtc-sdk#2} Cr-Branched-From: c276aee-refs/heads/main@{#35313}
1 parent ae43489 commit 8ad555b

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

pc/webrtc_sdp.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ static const char kDefaultSctpmapProtocol[] = "webrtc-datachannel";
256256
// types.
257257
const int kWildcardPayloadType = -1;
258258

259+
// Maximum number of channels allowed.
260+
static const size_t kMaxNumberOfChannels = 24;
261+
259262
struct SsrcInfo {
260263
uint32_t ssrc_id;
261264
std::string cname;
@@ -3627,6 +3630,10 @@ bool ParseRtpmapAttribute(const std::string& line,
36273630
return false;
36283631
}
36293632
}
3633+
if (channels > kMaxNumberOfChannels) {
3634+
return ParseFailed(line, "At most 24 channels are supported.", error);
3635+
}
3636+
36303637
AudioContentDescription* audio_desc = media_desc->as_audio();
36313638
UpdateCodec(payload_type, encoding_name, clock_rate, 0, channels,
36323639
audio_desc);

pc/webrtc_sdp_unittest.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4694,3 +4694,15 @@ TEST_F(WebRtcSdpTest, IllegalMidCharacterValue) {
46944694
Replace("a=mid:", "a=mid:[]", &sdp);
46954695
ExpectParseFailure(std::string(sdp), "a=mid:[]");
46964696
}
4697+
4698+
TEST_F(WebRtcSdpTest, MaxChannels) {
4699+
std::string sdp =
4700+
"v=0\r\n"
4701+
"o=- 11 22 IN IP4 127.0.0.1\r\n"
4702+
"s=-\r\n"
4703+
"t=0 0\r\n"
4704+
"m=audio 49232 RTP/AVP 108\r\n"
4705+
"a=rtpmap:108 ISAC/16000/512\r\n";
4706+
4707+
ExpectParseFailure(sdp, "a=rtpmap:108 ISAC/16000/512");
4708+
}

0 commit comments

Comments
 (0)