Skip to content

Commit

Permalink
Merge pull request #2885 from john08burke/multipart_crash
Browse files Browse the repository at this point in the history
pvar: fix crash when parsing multi-part body with negative index
(cherry picked from commit cd85314)
  • Loading branch information
bogdan-iancu committed Sep 12, 2022
1 parent f3c6ed2 commit c525399
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 c525399

Please sign in to comment.