Skip to content

Commit

Permalink
sdp: reject large number of channels
Browse files Browse the repository at this point in the history
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

Change-Id: Iba8e3185a1f235b846fed9c154e66fb3983664ed
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/238980
Reviewed-by: Harald Alvestrand <[email protected]>
Commit-Queue: Philipp Hancke <[email protected]>
Cr-Commit-Position: refs/heads/main@{#35440}
  • Loading branch information
fippo authored and WebRTC LUCI CQ committed Nov 30, 2021
1 parent 6c167d8 commit d58ac5a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pc/webrtc_sdp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ static const char kDefaultSctpmapProtocol[] = "webrtc-datachannel";
// types.
const int kWildcardPayloadType = -1;

// Maximum number of channels allowed.
static const size_t kMaxNumberOfChannels = 24;

struct SsrcInfo {
uint32_t ssrc_id;
std::string cname;
Expand Down Expand Up @@ -3628,6 +3631,10 @@ bool ParseRtpmapAttribute(const std::string& line,
return false;
}
}
if (channels > kMaxNumberOfChannels) {
return ParseFailed(line, "At most 24 channels are supported.", error);
}

AudioContentDescription* audio_desc = media_desc->as_audio();
UpdateCodec(payload_type, encoding_name, clock_rate, 0, channels,
audio_desc);
Expand Down
12 changes: 12 additions & 0 deletions pc/webrtc_sdp_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4694,3 +4694,15 @@ TEST_F(WebRtcSdpTest, IllegalMidCharacterValue) {
Replace("a=mid:", "a=mid:[]", &sdp);
ExpectParseFailure(std::string(sdp), "a=mid:[]");
}

TEST_F(WebRtcSdpTest, MaxChannels) {
std::string sdp =
"v=0\r\n"
"o=- 11 22 IN IP4 127.0.0.1\r\n"
"s=-\r\n"
"t=0 0\r\n"
"m=audio 49232 RTP/AVP 108\r\n"
"a=rtpmap:108 ISAC/16000/512\r\n";

ExpectParseFailure(sdp, "a=rtpmap:108 ISAC/16000/512");
}

0 comments on commit d58ac5a

Please sign in to comment.