Skip to content

Commit

Permalink
core: parser - more details in log messages for parsing headers
Browse files Browse the repository at this point in the history
  • Loading branch information
miconda committed Aug 20, 2018
1 parent 1af0bd7 commit e0ae8f1
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/core/parser/msg_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ char* get_hdr_field(char* const buf, char* const end, struct hdr_field* const hd
hdr->body.len=tmp-hdr->body.s;
DBG("<%.*s> [%d]; uri=[%.*s]\n", hdr->name.len, ZSW(hdr->name.s),
hdr->body.len, to_b->uri.len, ZSW(to_b->uri.s));
DBG("to body [%.*s], to tag [%.*s]\n", to_b->body.len, ZSW(to_b->body.s), to_b->tag_value.len, ZSW(to_b->tag_value.s));
DBG("to body [%.*s], to tag [%.*s]\n", to_b->body.len,
ZSW(to_b->body.s), to_b->tag_value.len,
ZSW(to_b->tag_value.s));
break;
case HDR_CONTENTLENGTH_T:
hdr->body.s=tmp;
Expand Down Expand Up @@ -251,8 +253,10 @@ char* get_hdr_field(char* const buf, char* const end, struct hdr_field* const hd
match=q_memchr(tmp, '\n', end-tmp);
if (match){
match++;
}else {
ERR("bad body for <%s>(%d)\n", hdr->name.s, hdr->type);
} else {
ERR("no eol - bad body for <%.*s> (hdr type: %d) [%.*s]\n",
hdr->name.len, hdr->name.s,
hdr->type, ((end-tmp)>128)?128:(int)(end-tmp), tmp);
/* abort(); */
tmp=end;
goto error;
Expand All @@ -263,7 +267,8 @@ char* get_hdr_field(char* const buf, char* const end, struct hdr_field* const hd
hdr->body.len=match-hdr->body.s;
break;
default:
BUG("unknown header type %d\n", hdr->type);
BUG("unknown header type %d [%.*s]\n", hdr->type,
((end-buf)>128)?128:(int)(end-buf), buf);
goto error;
}
/* jku: if \r covered by current length, shrink it */
Expand Down Expand Up @@ -328,7 +333,8 @@ int parse_headers(struct sip_msg* const msg, const hdr_flags_t flags, const int
rest=get_hdr_field(tmp, end, hf);
switch (hf->type){
case HDR_ERROR_T:
ERR("bad header field [%.*s]\n", (end-tmp>20)?20:(int)(end-tmp), tmp);
ERR("bad header field [%.*s]\n",
(end-tmp>100)?100:(int)(end-tmp), tmp);
goto error;
case HDR_EOH_T:
msg->eoh=tmp; /* or rest?*/
Expand Down

0 comments on commit e0ae8f1

Please sign in to comment.