Skip to content

Commit

Permalink
b2b_logic: fix possible crash after peer entity is disconnected
Browse files Browse the repository at this point in the history
The crash would happen when a receiving a request and the current entity
has no peer.
  • Loading branch information
rvlad-patrascu committed Sep 16, 2021
1 parent 067b547 commit afbff6a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions modules/b2b_logic/logic.c
Expand Up @@ -2008,18 +2008,21 @@ int b2b_logic_notify_request(int src, struct sip_msg* msg, str* key, str* body,
}
goto send_usual_request;
} else {
if(tuple->state != B2B_NOTDEF_STATE)
if(tuple->state != B2B_NOTDEF_STATE && peer)
peer->sdp_type = body->len ? B2BL_SDP_NORMAL : B2BL_SDP_LATE;

cur_route_ctx.entity_type = src;
if (pkg_str_dup(&cur_route_ctx.entity_key, key) < 0) {
LM_ERR("Out of pkg memory!\n");
goto error;
}
cur_route_ctx.peer_type = peer->type;
if (pkg_str_dup(&cur_route_ctx.peer_key, &peer->key) < 0) {
LM_ERR("Out of pkg memory!\n");
goto error;

if (peer) {
cur_route_ctx.peer_type = peer->type;
if (pkg_str_dup(&cur_route_ctx.peer_key, &peer->key) < 0) {
LM_ERR("Out of pkg memory!\n");
goto error;
}
}

lock_release(&b2bl_htable[hash_index].lock);
Expand All @@ -2030,7 +2033,8 @@ int b2b_logic_notify_request(int src, struct sip_msg* msg, str* key, str* body,
cur_route_ctx.flags &= ~B2BL_RT_REQ_CTX;

pkg_free(cur_route_ctx.entity_key.s);
pkg_free(cur_route_ctx.peer_key.s);
if (peer)
pkg_free(cur_route_ctx.peer_key.s);
}

goto done;
Expand Down

0 comments on commit afbff6a

Please sign in to comment.