neels has submitted this change. ( https://gerrit.osmocom.org/c/osmo-mgw/+/33534 )
Change subject: mgcp: fix "L: a:" header parsing: heed ";" separator ......................................................................
mgcp: fix "L: a:" header parsing: heed ";" separator
In the "L: a:" header, read the first codec name only up to the ";" separator, and ignore the rest.
According to RFC-2705, the "L: a:" header may include multiple codecs like "GSM-EFR;GSM" in:
L: p:20, a:GSM-EFR;GSM, nt:IN
osmo-mgw can handle only a single codec here. Since recently, osmo-msc is our first client that may actually send more than one codec. This uncovered a bug that leads to failing voice calls:
* osmo-mgw parses the entire list "GSM-EFR;GSM" as a single codec name, * puts that into the ptmap without scrutiny, * and even sends it back in the OK response, in the *SDP* part, as a single "GSM-EFR;GSM" codec entry.
We do not care very much about the "a:" codec list, because we always establish codecs via SDP later. So all we need to fix this is: parse the first codec done correctly, and ignore the rest.
Related: OS#6081 Change-Id: I0342e85b32ed89f3a1fdb6131c3c8ded8f47a455 --- M src/libosmo-mgcp/mgcp_protocol.c 1 file changed, 33 insertions(+), 2 deletions(-)
Approvals: Jenkins Builder: Verified falconia: Looks good to me, but someone else must approve fixeria: Looks good to me, but someone else must approve osmith: Looks good to me, but someone else must approve neels: Looks good to me, approved
diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c index 80e0f8a..978af42 100644 --- a/src/libosmo-mgcp/mgcp_protocol.c +++ b/src/libosmo-mgcp/mgcp_protocol.c @@ -672,8 +672,8 @@ case 'a': /* FIXME: LCO also supports the negotiation of more than one codec. * (e.g. a:PCMU;G726-32) But this implementation only supports a single - * codec only. */ - if (sscanf(lco_id + 1, ":%16[^,]", codec) == 1) { + * codec only. Ignoring all but the first codec. */ + if (sscanf(lco_id + 1, ":%16[^,;]", codec) == 1) { talloc_free(lco->codec); /* MGCP header is case insensive, and we'll need codec in uppercase when using it later: */