Browse code

core: parser - check it is sip protocol for hdr parsing constraints

Daniel-Constantin Mierla authored on 15/10/2020 08:24:00
Showing 1 changed files
... ...
@@ -359,10 +359,12 @@ int parse_headers(struct sip_msg* const msg, const hdr_flags_t flags, const int
359 359
 				if (msg->callid==0) {
360 360
 					msg->callid=hf;
361 361
 				} else if(ksr_sip_parser_mode & KSR_SIP_PARSER_MODE_STRICT) {
362
-					LOG(cfg_get(core, core_cfg, sip_parser_log),
363
-							"duplicate Call-ID header field [%.*s]\n",
364
-							(end-tmp>100)?100:(int)(end-tmp), tmp);
365
-					goto  error;
362
+					if(IS_SIP(msg)) {
363
+						LOG(cfg_get(core, core_cfg, sip_parser_log),
364
+								"duplicate Call-ID header field [%.*s]\n",
365
+								(end-tmp>100)?100:(int)(end-tmp), tmp);
366
+						goto  error;
367
+					}
366 368
 				}
367 369
 				msg->parsed_flag|=HDR_CALLID_F;
368 370
 				break;
... ...
@@ -374,10 +376,12 @@ int parse_headers(struct sip_msg* const msg, const hdr_flags_t flags, const int
374 376
 				if (msg->to==0) {
375 377
 					msg->to=hf;
376 378
 				} else if(ksr_sip_parser_mode & KSR_SIP_PARSER_MODE_STRICT) {
377
-					LOG(cfg_get(core, core_cfg, sip_parser_log),
378
-							"duplicate To header field [%.*s]\n",
379
-							(end-tmp>100)?100:(int)(end-tmp), tmp);
380
-					goto  error;
379
+					if(IS_SIP(msg)) {
380
+						LOG(cfg_get(core, core_cfg, sip_parser_log),
381
+								"duplicate To header field [%.*s]\n",
382
+								(end-tmp>100)?100:(int)(end-tmp), tmp);
383
+						goto  error;
384
+					}
381 385
 				}
382 386
 				msg->parsed_flag|=HDR_TO_F;
383 387
 				break;
... ...
@@ -385,9 +389,12 @@ int parse_headers(struct sip_msg* const msg, const hdr_flags_t flags, const int
385 389
 				if (msg->cseq==0) {
386 390
 					msg->cseq=hf;
387 391
 				} else if(ksr_sip_parser_mode & KSR_SIP_PARSER_MODE_STRICT) {
388
-					ERR("duplicate CSeq header field [%.*s]\n",
389
-						(end-tmp>100)?100:(int)(end-tmp), tmp);
390
-					goto  error;
392
+					if(IS_SIP(msg)) {
393
+						LOG(cfg_get(core, core_cfg, sip_parser_log),
394
+								"duplicate CSeq header field [%.*s]\n",
395
+								(end-tmp>100)?100:(int)(end-tmp), tmp);
396
+						goto  error;
397
+					}
391 398
 				}
392 399
 				msg->parsed_flag|=HDR_CSEQ_F;
393 400
 				break;
... ...
@@ -395,9 +402,12 @@ int parse_headers(struct sip_msg* const msg, const hdr_flags_t flags, const int
395 402
 				if (msg->from==0) {
396 403
 					msg->from=hf;
397 404
 				} else if(ksr_sip_parser_mode & KSR_SIP_PARSER_MODE_STRICT) {
398
-					ERR("duplicate From header field [%.*s]\n",
399
-						(end-tmp>100)?100:(int)(end-tmp), tmp);
400
-					goto  error;
405
+					if(IS_SIP(msg)) {
406
+						LOG(cfg_get(core, core_cfg, sip_parser_log),
407
+								"duplicate From header field [%.*s]\n",
408
+								(end-tmp>100)?100:(int)(end-tmp), tmp);
409
+						goto  error;
410
+					}
401 411
 				}
402 412
 				msg->parsed_flag|=HDR_FROM_F;
403 413
 				break;
... ...
@@ -409,10 +419,12 @@ int parse_headers(struct sip_msg* const msg, const hdr_flags_t flags, const int
409 419
 				if(msg->maxforwards==0) {
410 420
 					msg->maxforwards=hf;
411 421
 				} else {
412
-					LOG(cfg_get(core, core_cfg, sip_parser_log),
413
-							"duplicate Max-Forwards header field [%.*s]\n",
414
-							(end-tmp>100)?100:(int)(end-tmp), tmp);
415
-					goto  error;
422
+					if(IS_SIP(msg)) {
423
+						LOG(cfg_get(core, core_cfg, sip_parser_log),
424
+								"duplicate Max-Forwards header field [%.*s]\n",
425
+								(end-tmp>100)?100:(int)(end-tmp), tmp);
426
+						goto  error;
427
+					}
416 428
 				}
417 429
 				msg->parsed_flag|=HDR_MAXFORWARDS_F;
418 430
 				break;
... ...
@@ -432,10 +444,12 @@ int parse_headers(struct sip_msg* const msg, const hdr_flags_t flags, const int
432 444
 				if (msg->content_length==0) {
433 445
 					msg->content_length = hf;
434 446
 				} else if(ksr_sip_parser_mode & KSR_SIP_PARSER_MODE_STRICT) {
435
-					LOG(cfg_get(core, core_cfg, sip_parser_log),
436
-							"duplicate Content-Length header field [%.*s]\n",
437
-							(end-tmp>100)?100:(int)(end-tmp), tmp);
438
-					goto  error;
447
+					if(IS_SIP(msg)) {
448
+						LOG(cfg_get(core, core_cfg, sip_parser_log),
449
+								"duplicate Content-Length header field [%.*s]\n",
450
+								(end-tmp>100)?100:(int)(end-tmp), tmp);
451
+						goto  error;
452
+					}
439 453
 				}
440 454
 				msg->parsed_flag|=HDR_CONTENTLENGTH_F;
441 455
 				break;