소스 검색

Merge pull request #1561 from tdimitrov/pcscf-secagree-dealloc

Proper deallocation for the ipsec parameters in contact for IMS PCSCF modules
Daniel-Constantin Mierla 7 년 전
부모
커밋
9a72a8ab26
3개의 변경된 파일20개의 추가작업 그리고 9개의 파일을 삭제
  1. 12 5
      src/modules/ims_registrar_pcscf/sec_agree.c
  2. 0 2
      src/modules/ims_registrar_pcscf/sec_agree.h
  3. 8 2
      src/modules/ims_usrloc_pcscf/pcontact.c

+ 12 - 5
src/modules/ims_registrar_pcscf/sec_agree.c

@@ -69,7 +69,7 @@ static int process_sec_agree_param(str name, str value, ipsec_t *ret)
         SEC_COPY_STR_PARAM(ret->mod, value);
     }
     else if(strncasecmp(name.s, "ealg", name.len) == 0) {
-        SEC_COPY_STR_PARAM(ret->r_alg, value);
+        SEC_COPY_STR_PARAM(ret->r_ealg, value);
     }
     else if(strncasecmp(name.s, "spi-c", name.len) == 0) {
         ret->spi_uc = parse_digits(value);
@@ -201,20 +201,27 @@ static security_t* parse_sec_agree(struct hdr_field* h)
     return params;
 
 cleanup:
-    if(params) {
+    // The same piece of code also lives in modules/ims_usrloc_pcscf/pcontact.c
+    // Function - free_security()
+    // Keep them in sync!
+    if (params) {
         shm_free(params->sec_header.s);
 
-        if(params->data.ipsec) {
+        if(params->type == SECURITY_IPSEC && params->data.ipsec) {
+            shm_free(params->data.ipsec->ealg.s);
+            shm_free(params->data.ipsec->r_ealg.s);
+            shm_free(params->data.ipsec->ck.s);
+            shm_free(params->data.ipsec->alg.s);
             shm_free(params->data.ipsec->r_alg.s);
+            shm_free(params->data.ipsec->ik.s);
             shm_free(params->data.ipsec->prot.s);
             shm_free(params->data.ipsec->mod.s);
-            shm_free(params->data.ipsec->ealg.s);
-
             shm_free(params->data.ipsec);
         }
 
         shm_free(params);
     }
+
     return NULL;
 }
 

+ 0 - 2
src/modules/ims_registrar_pcscf/sec_agree.h

@@ -32,6 +32,4 @@
  */
 security_t* cscf_get_security(struct sip_msg *msg);
 
-void free_security_t(security_t *params);
-
 #endif // SEC_AGREE_H

+ 8 - 2
src/modules/ims_usrloc_pcscf/pcontact.c

@@ -112,6 +112,11 @@ void free_ppublic(ppublic_t* _p)
 	shm_free(_p);
 }
 
+
+// The same piece of code also lives in modules/ims_registrar_pcscf/sec_agree.c
+// Function - parse_sec_agree()
+// goto label - cleanup
+// Keep them in sync!
 void free_security(security_t* _p)
 {
     if (!_p)
@@ -137,8 +142,9 @@ void free_security(security_t* _p)
         case SECURITY_TLS:
             shm_free(_p->data.tls);
         break;
-
-        default: // Nothing to deallocate
+        
+        case SECURITY_NONE:
+            //Nothing to deallocate
         break;
     }