[sr-dev] git:master:e0ae8f18: core: parser - more details in log messages for parsing headers

Daniel-Constantin Mierla miconda at gmail.com
Mon Aug 20 11:39:30 CEST 2018


Module: kamailio
Branch: master
Commit: e0ae8f18503fcd26cde027360b8fd37223105ab7
URL: https://github.com/kamailio/kamailio/commit/e0ae8f18503fcd26cde027360b8fd37223105ab7

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2018-08-20T11:38:44+02:00

core: parser - more details in log messages for parsing headers

---

Modified: src/core/parser/msg_parser.c

---

Diff:  https://github.com/kamailio/kamailio/commit/e0ae8f18503fcd26cde027360b8fd37223105ab7.diff
Patch: https://github.com/kamailio/kamailio/commit/e0ae8f18503fcd26cde027360b8fd37223105ab7.patch

---

diff --git a/src/core/parser/msg_parser.c b/src/core/parser/msg_parser.c
index 0420dcd172..03610dc1f9 100644
--- a/src/core/parser/msg_parser.c
+++ b/src/core/parser/msg_parser.c
@@ -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;
@@ -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;
@@ -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 */
@@ -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?*/




More information about the sr-dev mailing list