Skip to content

Commit

Permalink
- drop the lumps (del or anchors) pointing inside a deleted area - th…
Browse files Browse the repository at this point in the history
…is will solve many inconsistencies in regards to overalapping of different lumps (del and add) over the same part of the message. Ex : change From HDR and later remove it.

  This is an experimental fix, need to be tested to see if there are any side effects.
  • Loading branch information
bogdan-iancu committed Jun 4, 2013
1 parent 027e7d0 commit 095aaa9
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions msg_translator.c
Expand Up @@ -649,22 +649,30 @@ int lumps_len(struct sip_msg* msg, struct lump* lumps,
break;
case LUMP_DEL:
/* fix overlapping deleted zones */
if (t->u.offset < s_offset){
/* change len */
if (t->len>s_offset-t->u.offset)
t->len-=s_offset-t->u.offset;
else t->len=0;
t->u.offset=s_offset;
//if (t->u.offset < s_offset){
// /* change len */
// if (t->len>s_offset-t->u.offset)
// t->len-=s_offset-t->u.offset;
// else t->len=0;
// t->u.offset=s_offset;
//}
/* lump inside a delete area ? */
if (s_offset > t->u.offset) {
continue;
}
s_offset=t->u.offset+t->len;
new_len-=t->len;
break;
case LUMP_NOP:
/* fix offset if overlapping on a deleted zone */
if (t->u.offset < s_offset){
t->u.offset=s_offset;
}else
s_offset=t->u.offset;
//if (t->u.offset < s_offset){
// t->u.offset=s_offset;
//}else
// s_offset=t->u.offset;
/* lump inside a delete area ? */
if (s_offset<t->u.offset) {
continue;
}
/* do nothing */
break;
default:
Expand Down Expand Up @@ -1043,8 +1051,12 @@ void process_lumps( struct sip_msg* msg,
break;
case LUMP_NOP:
case LUMP_DEL:
/* skip this lump if the "offset" is still in a "deleted" area */
if (s_offset > t->u.offset) {
continue;
}
/* copy till offset */
if (s_offset>t->u.offset){
if (s_offset>t->u.offset){ /* this should never happen !! */
LM_WARN("(%d) overlapped lumps offsets,"
" ignoring(%x, %x)\n", t->op, s_offset,t->u.offset);
/* this should've been fixed above (when computing len) */
Expand Down

0 comments on commit 095aaa9

Please sign in to comment.