Skip to content

Commit

Permalink
Fix computing the size to clone for a body part
Browse files Browse the repository at this point in the history
Take the optional header len into account also when cloning a body part struct.
This particular bug occured when using add_body_part() with extra hdr parameter in conjunction with an async() operation (or failure route)
Credits for reporting and helping with repoducing this go to @thuroc
Fixes #3067

(cherry picked from commit a042588)
  • Loading branch information
bogdan-iancu committed Jun 27, 2023
1 parent dfb9b4f commit 9ea7d54
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion parser/parse_body.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ int clone_sip_msg_body(struct sip_msg *src_msg, struct sip_msg *dst_msg,
extra_len = 0;
} else {
extra_len = (p->flags&SIP_BODY_PART_FLAG_NEW) ?
p->mime_s.len+p->body.len : 0 ;
p->mime_s.len+p->body.len+p->headers.len : 0 ;
if((np->next=func_malloc(my_malloc, sizeof(struct body_part)+extra_len))==NULL){
LM_ERR("failed to allocate new body_part clone (shared=%d)\n",
shared);
Expand Down

0 comments on commit 9ea7d54

Please sign in to comment.