Browse code

- fixed crash caused by previous bug-fix (reported by Ingo Wolfsberger)

Jan Janak authored on 30/05/2005 13:59:15
Showing 1 changed files
... ...
@@ -274,7 +274,7 @@ static inline int clone_authorized_hooks(struct sip_msg* new,
274 274
 
275 275
 #define AUTH_BODY_SIZE sizeof(struct auth_body)
276 276
 
277
-
277
+#define HOOK_SET(hook) (new_msg->hook != org_msg->hook)
278 278
 
279 279
 struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg, int *sip_msg_len )
280 280
 {
... ...
@@ -287,7 +287,6 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg, int *sip_msg_len )
287 287
 	struct lump_rpl   *rpl_lump, **rpl_lump_anchor;
288 288
 	char              *p;
289 289
 
290
-
291 290
 	/*computing the length of entire sip_msg structure*/
292 291
 	len = ROUND4(sizeof( struct sip_msg ));
293 292
 	/*we will keep only the original msg +ZT */
... ...
@@ -416,6 +415,7 @@ do { \
416 416
 	new_msg = (struct sip_msg*)p;
417 417
 	/* sip msg structure */
418 418
 	memcpy( new_msg , org_msg , sizeof(struct sip_msg) );
419
+
419 420
 	new_msg->msg_flags |= FL_SHM_CLONE;
420 421
 	p += ROUND4(sizeof(struct sip_msg));
421 422
 	new_msg->add_rm = 0;
... ...
@@ -465,9 +465,10 @@ do { \
465 465
 			org_msg->first_line.u.reply.reason.s );
466 466
 	}
467 467
 
468
-	/*headers list*/
469
-	new_msg->via1=0;
470
-	new_msg->via2=0;
468
+       /*headers list*/
469
+       new_msg->via1=0;
470
+       new_msg->via2=0;
471
+
471 472
 	for( hdr=org_msg->headers,last_hdr=0 ; hdr ; hdr=hdr->next )
472 473
 	{
473 474
 		new_hdr = (struct hdr_field*)p;
... ...
@@ -529,14 +530,14 @@ do { \
529 529
 				((struct cseq_body*)new_hdr->parsed)->method.s =
530 530
 					translate_pointer(new_msg->buf ,org_msg->buf,
531 531
 					((struct cseq_body*)hdr->parsed)->method.s );
532
-				if (new_msg->cseq == 0) new_msg->cseq = new_hdr;
532
+				if (!HOOK_SET(cseq)) new_msg->cseq = new_hdr;
533 533
 				break;
534 534
 			case HDR_TO_T:
535 535
 			case HDR_FROM_T:
536 536
 				if (hdr->type == HDR_TO_T) {
537
-					if (new_msg->to == 0) new_msg->to = new_hdr;
537
+					if (!HOOK_SET(to)) new_msg->to = new_hdr;
538 538
 				} else {
539
-					if (new_msg->from == 0) new_msg->from = new_hdr;
539
+					if (!HOOK_SET(from)) new_msg->from = new_hdr;
540 540
 				}
541 541
 				/* From header might be unparsed */
542 542
 				if (!hdr->parsed) break;
... ...
@@ -579,44 +580,44 @@ do { \
579 579
 				}
580 580
 				break;
581 581
 			case HDR_CALLID_T:
582
-				if (new_msg->callid == 0) {
582
+				if (!HOOK_SET(callid)) {
583 583
 					new_msg->callid = new_hdr;
584 584
 				}
585 585
 				break;
586 586
 			case HDR_CONTACT_T:
587
-				if (new_msg->contact == 0) {
587
+				if (!HOOK_SET(contact)) {
588 588
 					new_msg->contact = new_hdr;
589 589
 				}
590 590
 				break;
591 591
 			case HDR_MAXFORWARDS_T:
592
-				if (new_msg->maxforwards == 0) {
592
+				if (!HOOK_SET(maxforwards)) {
593 593
 					new_msg->maxforwards = new_hdr;
594 594
 				}
595 595
 				break;
596 596
 			case HDR_ROUTE_T:
597
-				if (new_msg->route == 0) {
597
+				if (!HOOK_SET(route)) {
598 598
 					new_msg->route = new_hdr;
599 599
 				}
600 600
 				break;
601 601
 			case HDR_RECORDROUTE_T:
602
-				if (new_msg->record_route == 0) {
602
+				if (!HOOK_SET(record_route)) {
603 603
 					new_msg->record_route = new_hdr;
604 604
 				}
605 605
 				break;
606 606
 			case HDR_CONTENTTYPE_T:
607
-				if (new_msg->content_type == 0) {
607
+				if (!HOOK_SET(content_type)) {
608 608
 					new_msg->content_type = new_hdr;
609 609
 					new_msg->content_type->parsed = hdr->parsed;
610 610
 				}
611 611
 				break;
612 612
 			case HDR_CONTENTLENGTH_T:
613
-				if (new_msg->content_length == 0) {
613
+				if (!HOOK_SET(content_length)) {
614 614
 					new_msg->content_length = new_hdr;
615 615
 					new_msg->content_length->parsed = hdr->parsed;
616 616
 				}
617 617
 				break;
618 618
 			case HDR_AUTHORIZATION_T:
619
-				if (new_msg->authorization == 0) {
619
+				if (!HOOK_SET(authorization)) {
620 620
 					new_msg->authorization = new_hdr;
621 621
 				}
622 622
 				if (hdr->parsed) {
... ...
@@ -625,12 +626,12 @@ do { \
625 625
 				}
626 626
 				break;
627 627
 			case HDR_EXPIRES_T:
628
-				if (new_msg->expires == 0) {
628
+				if (!HOOK_SET(expires)) {
629 629
 					new_msg->expires = new_hdr;
630 630
 				}
631 631
 				break;
632 632
 			case HDR_PROXYAUTH_T:
633
-				if (new_msg->proxy_auth == 0) {
633
+				if (!HOOK_SET(proxy_auth)) {
634 634
 					new_msg->proxy_auth = new_hdr;
635 635
 				}
636 636
 				if (hdr->parsed) {
... ...
@@ -639,67 +640,67 @@ do { \
639 639
 				}
640 640
 				break;
641 641
 			case HDR_SUPPORTED_T:
642
-				if (new_msg->supported == 0) {
642
+				if (!HOOK_SET(supported)) {
643 643
 					new_msg->supported = new_hdr;
644 644
 				}
645 645
 				break;
646 646
 			case HDR_PROXYREQUIRE_T:
647
-				if (new_msg->proxy_require == 0) {
647
+				if (!HOOK_SET(proxy_require)) {
648 648
 					new_msg->proxy_require = new_hdr;
649 649
 				}
650 650
 				break;
651 651
 			case HDR_UNSUPPORTED_T:
652
-				if (new_msg->unsupported == 0) {
652
+				if (!HOOK_SET(unsupported)) {
653 653
 					new_msg->unsupported = new_hdr;
654 654
 				}
655 655
 				break;
656 656
 			case HDR_ALLOW_T:
657
-				if (new_msg->allow == 0) {
657
+				if (!HOOK_SET(allow)) {
658 658
 					new_msg->allow = new_hdr;
659 659
 				}
660 660
 				break;
661 661
 			case HDR_EVENT_T:
662
-				if (new_msg->event == 0) {
662
+				if (!HOOK_SET(event)) {
663 663
 					new_msg->event = new_hdr;
664 664
 				}
665 665
 				break;
666 666
 			case HDR_ACCEPT_T:
667
-				if (new_msg->accept == 0) {
667
+				if (!HOOK_SET(accept)) {
668 668
 					new_msg->accept = new_hdr;
669 669
 				}
670 670
 				break;
671 671
 			case HDR_ACCEPTLANGUAGE_T:
672
-				if (new_msg->accept_language == 0) {
672
+				if (!HOOK_SET(accept_language)) {
673 673
 					new_msg->accept_language = new_hdr;
674 674
 				}
675 675
 				break;
676 676
 			case HDR_ORGANIZATION_T:
677
-				if (new_msg->organization == 0) {
677
+				if (!HOOK_SET(organization)) {
678 678
 					new_msg->organization = new_hdr;
679 679
 				}
680 680
 				break;
681 681
 			case HDR_PRIORITY_T:
682
-				if (new_msg->priority == 0) {
682
+				if (!HOOK_SET(priority)) {
683 683
 					new_msg->priority = new_hdr;
684 684
 				}
685 685
 				break;
686 686
 			case HDR_SUBJECT_T:
687
-				if (new_msg->subject == 0) {
687
+				if (!HOOK_SET(subject)) {
688 688
 					new_msg->subject = new_hdr;
689 689
 				}
690 690
 				break;
691 691
 			case HDR_USERAGENT_T:
692
-				if (new_msg->user_agent == 0) {
692
+				if (!HOOK_SET(user_agent)) {
693 693
 					new_msg->user_agent = new_hdr;
694 694
 				}
695 695
 				break;
696 696
 			case HDR_ACCEPTDISPOSITION_T:
697
-				if (new_msg->accept_disposition == 0) {
697
+				if (!HOOK_SET(accept_disposition)) {
698 698
 					new_msg->accept_disposition = new_hdr;
699 699
 				}
700 700
 				break;
701 701
 			case HDR_CONTENTDISPOSITION_T:
702
-				if (new_msg->content_disposition == 0) {
702
+				if (!HOOK_SET(content_disposition)) {
703 703
 					new_msg->content_disposition = new_hdr;
704 704
 				}
705 705
 				break;
... ...
@@ -781,8 +782,3 @@ do { \
781 781
 
782 782
 	return new_msg;
783 783
 }
784
-
785
-
786
-
787
-
788
-