[sr-dev] git:master:b3030a29: enum: free variable in case of error and safety check for returned pointer

Daniel-Constantin Mierla miconda at gmail.com
Mon Jul 3 10:58:16 CEST 2017


Module: kamailio
Branch: master
Commit: b3030a2965889a788093b2c372c1d7ac9441e8cc
URL: https://github.com/kamailio/kamailio/commit/b3030a2965889a788093b2c372c1d7ac9441e8cc

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2017-07-03T10:57:21+02:00

enum: free variable in case of error and safety check for returned pointer

---

Modified: src/modules/enum/enum.c

---

Diff:  https://github.com/kamailio/kamailio/commit/b3030a2965889a788093b2c372c1d7ac9441e8cc.diff
Patch: https://github.com/kamailio/kamailio/commit/b3030a2965889a788093b2c372c1d7ac9441e8cc.patch

---

diff --git a/src/modules/enum/enum.c b/src/modules/enum/enum.c
index e4cb1699ac..c8dcdc3751 100644
--- a/src/modules/enum/enum.c
+++ b/src/modules/enum/enum.c
@@ -405,6 +405,11 @@ int is_from_user_enum_helper(sip_msg_t *_msg, str *suffix, str *service)
 			zp = 0;
 			proto = PROTO_NONE;
 			he = sip_resolvehost(&luri.host, &zp, &proto);
+			if(he==NULL) {
+				LM_ERR("failed to resolve the host\n");
+				free_rdata_list(head); /*clean up*/
+				return -8;
+			}
 
 			hostent2ip_addr(&addr, he, 0);
 
@@ -948,11 +953,13 @@ int i_enum_query_helper(sip_msg_t *_msg, str *suffix, str *service)
 			if((ebl->apex_len > MAX_COMPONENT_SIZE)
 					|| (ebl->separator_len > MAX_COMPONENT_SIZE)) {
 				LM_ERR("EBL strings too long\n");
+				free_rdata_list(head);
 				return -1;
 			}
 
 			if(ebl->position > 15) {
 				LM_ERR("EBL position too large (%d)\n", ebl->position);
+				free_rdata_list(head);
 				return -1;
 			}
 
@@ -1306,4 +1313,4 @@ int ki_enum_pv_query_suffix_service(sip_msg_t *msg, str *ve164, str *vsuffix,
 		str *vservice)
 {
 	return enum_pv_query_helper(msg, ve164, vsuffix, vservice);
-}
\ No newline at end of file
+}




More information about the sr-dev mailing list