Browse Source

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

Dragos Vingarzan 9 năm trước cách đây
mục cha
commit
e575d6818f
2 tập tin đã thay đổi với 7 bổ sung5 xóa
  1. 6 4
      modules/cdp/authstatemachine.c
  2. 1 1
      modules/cdp/peermanager.c

+ 6 - 4
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");
 		}

+ 1 - 1
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;