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
This commit is contained in:
Neels Hofmeyr 2018-08-20 22:39:53 +02:00
parent dde80f3f61
commit 0a89e92a5e
1 changed files with 2 additions and 0 deletions

View File

@ -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;