Browse code

registrar - fix matches

Luis Azedo authored on 24/02/2015 09:12:26
Showing 1 changed files
... ...
@@ -686,19 +686,21 @@ int registered(struct sip_msg* _m, udomain_t* _d, str* _uri, int match_flag)
686 686
 		for (ptr = r->contacts; ptr; ptr = ptr->next) {
687 687
 			if(!VALID_CONTACT(ptr, act_time)) continue;
688 688
 			if (match_callid.s && /* optionally enforce tighter matching w/ Call-ID */
689
-				memcmp(match_callid.s,ptr->callid.s,match_callid.len))
689
+				match_callid.len > 0 &&
690
+				(match_callid.len != ptr->callid.len || 
691
+				memcmp(match_callid.s, ptr->callid.s, match_callid.len)))
690 692
 				continue;
691 693
 			if (match_received.s && /* optionally enforce tighter matching w/ ip:port */
692
-				memcmp(match_received.s,ptr->received.s,match_received.len))
694
+				match_received.len > 0 &&
695
+				(match_received.len != ptr->received.len || 
696
+				memcmp(match_received.s, ptr->received.s, match_received.len)))
693 697
 				continue;
694 698
 			if (match_contact.s && /* optionally enforce tighter matching w/ Contact */
695
-				memcmp(match_contact.s,ptr->c.s,match_contact.len))
699
+				match_contact.len > 0 &&
700
+				(match_contact.len != ptr->s.len || 
701
+				memcmp(match_contact.s, ptr->c.s, match_contact.len)))
696 702
 				continue;
697 703
 
698
-			ul.release_urecord(r);
699
-			ul.unlock_udomain(_d, &aor);
700
-			LM_DBG("'%.*s' found in usrloc\n", aor.len, ZSW(aor.s));
701
-
702 704
 			if(ptr->xavp!=NULL && reg_match_flag_param == 1) {
703 705
 				sr_xavp_t *xavp = xavp_clone_level_nodata(ptr->xavp);
704 706
 				if(xavp_add(xavp, NULL)<0) {
... ...
@@ -707,6 +709,10 @@ int registered(struct sip_msg* _m, udomain_t* _d, str* _uri, int match_flag)
707 709
 				}
708 710
 			}
709 711
 
712
+			ul.release_urecord(r);
713
+			ul.unlock_udomain(_d, &aor);
714
+			LM_DBG("'%.*s' found in usrloc\n", aor.len, ZSW(aor.s));
715
+
710 716
 			return 1;
711 717
 		}
712 718
 	}