From 0a89e92a5e03798831de506bc08092f21e84c5bf Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Mon, 20 Aug 2018 22:39:53 +0200 Subject: [PATCH] fix handling of "Wrong domain name" error If no endpoint was found, assert that the cause code indicates error, so that the remaining code path doesn't assume finding an endpoint was successful. Also fix find_endpoint() to return an error cause (not 0) in case it finds the domain name to be wrong. After this, the error described in OS#3488 simply results in a CRCX failure, not in a program crash. Related: OS#3488 Change-Id: I87e2d76c22603d6fef89907c3cf8f7965abf35a0 --- src/libosmo-mgcp/mgcp_msg.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libosmo-mgcp/mgcp_msg.c b/src/libosmo-mgcp/mgcp_msg.c index 8d22cc5f2..7378ddc5b 100644 --- a/src/libosmo-mgcp/mgcp_msg.c +++ b/src/libosmo-mgcp/mgcp_msg.c @@ -241,6 +241,7 @@ static struct mgcp_endpoint *find_endpoint(struct mgcp_config *cfg, /* Check if the domainname in the request is correct */ if (check_domain_name(cfg, mgcp)) { LOGP(DLMGCP, LOGL_ERROR, "Wrong domain name '%s'\n", mgcp); + *cause = -500; return NULL; } @@ -320,6 +321,7 @@ int mgcp_parse_header(struct mgcp_parse_data *pdata, char *data) if (!pdata->endp) { LOGP(DLMGCP, LOGL_ERROR, "Unable to find Endpoint `%s'\n", elem); + OSMO_ASSERT(cause < 0); return cause; } break;