Skip to content

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

@mrosu90

Description

@mrosu90

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions