Skip to content

Commit

Permalink
clusterer: fix crash after MI reload
Browse files Browse the repository at this point in the history
The crash was caused by accessing a dangling pointer to the capability
structure after it was freed.

Thanks to Suchi Sahoo from Five9 for reporting!
  • Loading branch information
rvlad-patrascu committed Jul 3, 2023
1 parent 8677212 commit cb8d631
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions modules/clusterer/clusterer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1793,6 +1793,9 @@ int preserve_reg_caps(cluster_info_t *new_info)
LM_ERR("Failed to duplicate capabilities info\n");
return -1;
}

update_shtags_sync_status_cap(cl->cluster_id,
new_cl->capabilities);
}

return 0;
Expand Down
23 changes: 23 additions & 0 deletions modules/clusterer/sharing_tags.c
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,29 @@ int shtag_set_sync_status(str *tag_name, int cluster_id, str *capability,
return 0;
}

void update_shtags_sync_status_cap(int cluster_id, struct local_cap *new_caps)
{
struct sharing_tag *tag;
struct shtag_sync_status *status;
struct local_cap *cap;

lock_start_write(shtags_lock);

for (tag = *shtags_list; tag; tag = tag->next) {
if (tag->cluster_id != cluster_id)
continue;

for (status=tag->sync_status; status; status=status->next)
for (cap = new_caps; cap; cap = cap->next)
if (!str_strcmp(&cap->reg.name, &status->capability->reg.name)) {
status->capability = cap;
break;
}
}

lock_stop_write(shtags_lock);
}

int shtag_sync_all_backup(int cluster_id, str *capability)
{
struct sharing_tag *tag;
Expand Down
2 changes: 2 additions & 0 deletions modules/clusterer/sharing_tags.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ int shtag_set_sync_status(str *tag_name, int cluster_id, str *capability,

int shtag_sync_all_backup(int cluster_id, str *capability);

void update_shtags_sync_status_cap(int cluster_id, struct local_cap *new_caps);

/* script vars related functions */
int var_get_sh_tag(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);

Expand Down

0 comments on commit cb8d631

Please sign in to comment.