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
This commit is contained in:
Neels Hofmeyr 2023-06-30 05:12:54 +02:00
parent 9423817311
commit e9989b9e76
1 changed files with 2 additions and 2 deletions

View File

@ -672,8 +672,8 @@ static int set_local_cx_options(void *ctx, struct mgcp_lco *lco,
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: */