Module: kamailio
Branch: master
Commit: 9a72a8ab26b281102bd6813d6c80adac6aecb88b
URL:
https://github.com/kamailio/kamailio/commit/9a72a8ab26b281102bd6813d6c80ada…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: GitHub <noreply(a)github.com>
Date: 2018-06-20T08:26:29+02:00
Merge pull request #1561 from tdimitrov/pcscf-secagree-dealloc
Proper deallocation for the ipsec parameters in contact for IMS PCSCF modules
---
Modified: src/modules/ims_registrar_pcscf/sec_agree.c
Modified: src/modules/ims_registrar_pcscf/sec_agree.h
Modified: src/modules/ims_usrloc_pcscf/pcontact.c
---
Diff:
https://github.com/kamailio/kamailio/commit/9a72a8ab26b281102bd6813d6c80ada…
Patch:
https://github.com/kamailio/kamailio/commit/9a72a8ab26b281102bd6813d6c80ada…
---
diff --git a/src/modules/ims_registrar_pcscf/sec_agree.c
b/src/modules/ims_registrar_pcscf/sec_agree.c
index bc72272189..099dbbfff3 100644
--- a/src/modules/ims_registrar_pcscf/sec_agree.c
+++ b/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;
}
diff --git a/src/modules/ims_registrar_pcscf/sec_agree.h
b/src/modules/ims_registrar_pcscf/sec_agree.h
index 421f30075b..958a79ca3b 100644
--- a/src/modules/ims_registrar_pcscf/sec_agree.h
+++ b/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
diff --git a/src/modules/ims_usrloc_pcscf/pcontact.c
b/src/modules/ims_usrloc_pcscf/pcontact.c
index 60d6b28132..76297bf1d9 100644
--- a/src/modules/ims_usrloc_pcscf/pcontact.c
+++ b/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;
}