[sr-dev] git:master:e575d681: cdp: initializing a variable to 0 and checking a return ptr for null to prevent crashes

Dragos Vingarzan dragos at corenetdynamics.com
Wed Jul 20 20:26:19 CEST 2016


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

Author: Dragos Vingarzan <dragos at corenetdynamics.com>
Committer: Dragos Vingarzan <dragos at corenetdynamics.com>
Date: 2016-07-20T17:38:24+02:00

cdp: initializing a variable to 0 and checking a return ptr for null to prevent crashes

---

Modified: modules/cdp/authstatemachine.c
Modified: modules/cdp/peermanager.c

---

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

---

diff --git a/modules/cdp/authstatemachine.c b/modules/cdp/authstatemachine.c
index b479080..203dfef 100644
--- a/modules/cdp/authstatemachine.c
+++ b/modules/cdp/authstatemachine.c
@@ -754,12 +754,14 @@ void Send_ASA(cdp_session_t* s, AAAMessage* msg) {
 			// the PCRF because TS 29.214 says no Destination-Host and no Auth-Application-Id
 			// in the ASA
 			LM_INFO("sending ASA to peer %.*s\n", avp->data.len, avp->data.s);
-			peer *p;
-			p = get_peer_by_fqdn(&avp->data);
-			if (!peer_send_msg(p, asa)) {
+			peer *p = get_peer_by_fqdn(&avp->data);
+			if (!p) {
+				LM_ERR("Peer not found\n");
+			}else if (!peer_send_msg(p, asa)) {
 				if (asa) AAAFreeMessage(&asa); //needed in frequency
-			} else
+			} else {
 				LM_INFO("success sending ASA\n");
+			}
 		} else if (!AAASendMessage(asa, 0, 0)) {
 			LM_ERR("Send_ASA() : error sending ASA\n");
 		}
diff --git a/modules/cdp/peermanager.c b/modules/cdp/peermanager.c
index bce1c0e..1d6f6a9 100644
--- a/modules/cdp/peermanager.c
+++ b/modules/cdp/peermanager.c
@@ -209,7 +209,7 @@ peer *get_peer_from_sock(int sock)
 peer *get_peer_from_fqdn(str fqdn,str realm)
 {
 	peer *i;
-	str dumb;
+	str dumb = {0,0};
 
 	lock_get(peer_list_lock);
 	i = peer_list->head;




More information about the sr-dev mailing list