Skip to content

Commit

Permalink
pvar: fix crash when parsing multi-part body with negative index in `…
Browse files Browse the repository at this point in the history
…$rb`
  • Loading branch information
john08burke committed Aug 4, 2022
1 parent 21cbcd6 commit 53679e1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pvar.c
Original file line number Diff line number Diff line change
Expand Up @@ -1697,9 +1697,16 @@ static int pv_get_msg_body(struct sip_msg *msg, pv_param_t *param,
if (idx<0) {
first_part_by_mime( &sbody->first, neg_index[1], mime );
neg_index[0] = neg_index[1];

if (neg_index[0]==NULL) {
LM_DBG("Body part not found for <%d>\n", mime);
return pv_get_null(msg, param, res);
}

/*distance=last_body_postition-searched_body_position*/
distance -= idx+1;
while (neg_index[1]->next) {
first_part_by_mime(neg_index[1]->next, neg_index[1], mime);
while (neg_index[1]) {
if (distance == 0) {
first_part_by_mime( neg_index[0]->next, neg_index[0], mime );
} else {
Expand Down

0 comments on commit 53679e1

Please sign in to comment.