Browse code

ims_ipsec_pcscf: safety check for pcontact search result

Daniel-Constantin Mierla authored on 04/05/2022 08:02:18
Showing 1 changed files
... ...
@@ -667,7 +667,7 @@ int ipsec_create(struct sip_msg* m, udomain_t* d, int _cflags)
667 667
 
668 668
     ul.lock_udomain(d, &ci.via_host, ci.via_port, ci.via_prot);
669 669
 
670
-    if (ul.get_pcontact(d, &ci, &pcontact, 0) != 0) {
670
+    if (ul.get_pcontact(d, &ci, &pcontact, 0) != 0 || pcontact==NULL) {
671 671
         LM_ERR("Contact doesn't exist\n");
672 672
         goto cleanup;
673 673
     }
... ...
@@ -810,7 +810,8 @@ int ipsec_forward(struct sip_msg* m, udomain_t* d, int _cflags)
810 810
 
811 811
     ul.lock_udomain(d, &ci.via_host, ci.via_port, ci.via_prot);
812 812
 
813
-    if (ul.get_pcontact(d, &ci, &pcontact, _cflags & IPSEC_REVERSE_SEARCH) != 0) {
813
+    if (ul.get_pcontact(d, &ci, &pcontact, _cflags & IPSEC_REVERSE_SEARCH) != 0
814
+    		|| pcontact==NULL) {
814 815
         LM_ERR("Contact doesn't exist\n");
815 816
         goto cleanup;
816 817
     }
... ...
@@ -967,7 +968,7 @@ int ipsec_destroy(struct sip_msg* m, udomain_t* d)
967 968
 
968 969
     ul.lock_udomain(d, &ci.via_host, ci.via_port, ci.via_prot);
969 970
 
970
-    if (ul.get_pcontact(d, &ci, &pcontact, 0) != 0) {
971
+    if (ul.get_pcontact(d, &ci, &pcontact, 0) != 0 || pcontact==NULL) {
971 972
         LM_ERR("Contact doesn't exist\n");
972 973
         goto cleanup;
973 974
     }