Skip to content

Commit

Permalink
Validate channel count before parsing Opus param string
Browse files Browse the repository at this point in the history
  • Loading branch information
cgutman committed Oct 16, 2024
1 parent 0fa805d commit dff1690
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/RtspConnection.c
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,11 @@ static bool sendVideoAnnounce(PRTSP_MESSAGE response, int* error) {
static int parseOpusConfigFromParamString(char* paramStr, int channelCount, POPUS_MULTISTREAM_CONFIGURATION opusConfig) {
int i;

if (channelCount > AUDIO_CONFIGURATION_MAX_CHANNEL_COUNT) {
Limelog("Invalid channel count: %d\n", channelCount);
return -1;
}

// Set channel count (included in the prefix, so not parsed below)
opusConfig->channelCount = channelCount;

Expand Down Expand Up @@ -760,6 +765,7 @@ static int parseOpusConfigurations(PRTSP_MESSAGE response) {
// Parse the normal quality Opus config
err = parseOpusConfigFromParamString(paramStart, channelCount, &NormalQualityOpusConfig);
if (err != 0) {
LC_ASSERT(err == 0);
return err;
}

Expand Down Expand Up @@ -788,6 +794,7 @@ static int parseOpusConfigurations(PRTSP_MESSAGE response) {
// Parse the high quality Opus config
err = parseOpusConfigFromParamString(paramStart, channelCount, &HighQualityOpusConfig);
if (err != 0) {
LC_ASSERT(err == 0);
return err;
}

Expand Down

0 comments on commit dff1690

Please sign in to comment.