Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array out of bounds access when Produce() is called using the last codec in Device's caps array #177

Open
mrosu90 opened this issue May 28, 2024 · 1 comment

Comments

@mrosu90
Copy link

mrosu90 commented May 28, 2024

Scenario:
Load a device with 3 codec caps: opus, pcma, pcmu.
Create a SendTransport & then call Produce restricting the codec by forcing pcmu.
In ortc.cpp reduceCodecs will check the Device caps array, it will get to pcmu which is the third and last element (idx == 2), and call isRtxCodec on it.

if (matchCodecs(codecs[idx], const_cast<json&>(*capCodec)))
{
    filteredCodecs.push_back(codecs[idx]);
    
    if (isRtxCodec(codecs[idx + 1]))
	    filteredCodecs.push_back(codecs[idx + 1]);
    
    break;
}

This will effectively force nlohmann::json object to do an out-of-bounds access. The library guards against this by adding a null object to the end of the array:.
image

This will throw further down the line when matchCodecstries to match the mimeType and it's looking for a string type not an obj type.

@ibc
Copy link
Member

ibc commented May 28, 2024

Thanks for reporting. We won't be able to fix is soon but won't forget.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants