nat: Verify that the endpoint from the assignment command exists

Make sure that the MSC endpoint exists on the NAT, otherwise
we end up trying to free this endpoint when the SCCP connection
is taken down and will corrupt our memory. This issue started
to pop up as we have reduced the number of endpoints to 60
to allow transcoding on them.
This commit is contained in:
Holger Hans Peter Freyther 2010-11-04 17:14:41 +01:00
parent f3d1ae7072
commit 1406977e7e
1 changed files with 8 additions and 1 deletions

View File

@ -75,7 +75,7 @@ int bsc_mgcp_assign_patch(struct sccp_connections *con, struct msgb *msg)
uint16_t cic;
uint8_t timeslot;
uint8_t multiplex;
int endp;
unsigned int endp;
if (!msg->l3h) {
LOGP(DNAT, LOGL_ERROR, "Assignment message should have l3h pointer.\n");
@ -100,6 +100,13 @@ int bsc_mgcp_assign_patch(struct sccp_connections *con, struct msgb *msg)
endp = mgcp_timeslot_to_endpoint(multiplex, timeslot);
if (endp >= con->bsc->nat->mgcp_cfg->number_endpoints) {
LOGP(DNAT, LOGL_ERROR,
"MSC attempted to assign bad endpoint 0x%x\n",
endp);
return -1;
}
/* find stale connections using that endpoint */
llist_for_each_entry(mcon, &con->bsc->nat->sccp_connections, list_entry) {
if (mcon->msc_endp == endp) {