From c1bf4694e72791ec67a75806e08e7f3ed9c058cb Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Tue, 14 May 2019 16:23:24 +0200 Subject: [PATCH] mgw, mgcp-li: Handle X-Osmux param name as case insensitive RFC3435 states most text (except SDP) must be handled as case insensitive. Related: OS#4001 Change-Id: Iac073f1db46569b46eddeaecc9934a2986bd50f1 --- src/libosmo-mgcp-client/mgcp_client.c | 7 ++++--- src/libosmo-mgcp/mgcp_msg.c | 4 ++-- src/libosmo-mgcp/mgcp_protocol.c | 6 ++++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/libosmo-mgcp-client/mgcp_client.c b/src/libosmo-mgcp-client/mgcp_client.c index d65a7990c..707432857 100644 --- a/src/libosmo-mgcp-client/mgcp_client.c +++ b/src/libosmo-mgcp-client/mgcp_client.c @@ -403,12 +403,12 @@ static int mgcp_parse_osmux_cid(const char *line) int osmux_cid; - if (strstr(line + 2, "Osmux: *")) { + if (strcasecmp(line + 2, "Osmux: *") == 0) { LOGP(DLMGCP, LOGL_DEBUG, "Parsed wilcard Osmux CID\n"); return -1; } - if (sscanf(line + 2, "Osmux: %u", &osmux_cid) != 1) { + if (sscanf(line + 2 + 7, "%u", &osmux_cid) != 1) { LOGP(DLMGCP, LOGL_ERROR, "Failed parsing Osmux in MGCP msg line: %s\n", line); return -2; @@ -602,7 +602,8 @@ static int parse_head_params(struct mgcp_response *r) goto exit; break; case 'X': - if (strncmp("Osmux: ", line + 2, strlen("Osmux: ")) == 0) { + case 'x': + if (strncasecmp("Osmux: ", line + 2, strlen("Osmux: ")) == 0) { rc = mgcp_parse_osmux_cid(line); if (rc < 0) { /* -1: we don't want wildcards in response. -2: error */ diff --git a/src/libosmo-mgcp/mgcp_msg.c b/src/libosmo-mgcp/mgcp_msg.c index a31bff46d..59e0e91da 100644 --- a/src/libosmo-mgcp/mgcp_msg.c +++ b/src/libosmo-mgcp/mgcp_msg.c @@ -360,12 +360,12 @@ int mgcp_parse_osmux_cid(const char *line) int osmux_cid; - if (strstr(line + 2, "Osmux: *")) { + if (strcasecmp(line + 2, "Osmux: *") == 0) { LOGP(DLMGCP, LOGL_DEBUG, "Parsed wilcard Osmux CID\n"); return -1; } - if (sscanf(line + 2, "Osmux: %u", &osmux_cid) != 1) { + if (sscanf(line + 2 + 7, "%u", &osmux_cid) != 1) { LOGP(DLMGCP, LOGL_ERROR, "Failed parsing Osmux in MGCP msg line: %s\n", line); return -2; diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c index 0831abbda..74926ad14 100644 --- a/src/libosmo-mgcp/mgcp_protocol.c +++ b/src/libosmo-mgcp/mgcp_protocol.c @@ -816,7 +816,8 @@ static struct msgb *handle_create_con(struct mgcp_parse_data *p) mode = (const char *)line + 3; break; case 'X': - if (strncmp("Osmux: ", line + 2, strlen("Osmux: ")) == 0) { + case 'x': + if (strncasecmp("Osmux: ", line + 2, strlen("Osmux: ")) == 0) { /* If osmux is disabled, just skip setting it up */ if (!p->endp->cfg->osmux) break; @@ -1099,7 +1100,8 @@ static struct msgb *handle_modify_con(struct mgcp_parse_data *p) silent = strcmp("noanswer", line + 3) == 0; break; case 'X': - if (strncmp("Osmux: ", line + 2, strlen("Osmux: ")) == 0) { + case 'x': + if (strncasecmp("Osmux: ", line + 2, strlen("Osmux: ")) == 0) { /* If osmux is disabled, just skip setting it up */ if (!p->endp->cfg->osmux) break;