meetecho / janus-gateway

Janus WebRTC Server
https://janus.conf.meetecho.com
GNU General Public License v3.0
8.17k stars 2.47k forks source link

When label is larger than 64, label is truncated and new context will… #3265

Closed veeting closed 1 year ago

veeting commented 1 year ago

We are facing an issue with the videoroom plugin and datachannels regarding the char label[64] in struct janus_sctp_channel.

Our videoroom IDs are usually 32 characters long and few other IDs have even more characters. In the videoroom plugin, the labels are built by Janus with the combination of 2 IDs, an underscore and a NULL character which ends up being a size of 66.

When label are larger than 64, the sctp.c source code is truncating the label value up to 64, but later, whenever the code searches for a label, the strcmp will always fail. Thus, the janus_sctp_channel context is never found.

We propose to extend the label size from 64 to 128.

This is an easy fix and a safe one and allows for string IDs in videoroom of a larger size.

The issue would still exists for label with higher size but 128 seems a better trade-off as videoroom IDs and publisher IDs of sizes between 32 and 64 may be common.

lminiero commented 1 year ago

Sounds like a reasonable trade-off, I'll backport the same fix to 0.x too :+1:

veeting commented 1 year ago

Thank you, @lminiero