[sr-dev] git:5.5:b6428ca8: dialog: safety checks for bind addr fields

Daniel-Constantin Mierla miconda at gmail.com
Thu Jun 10 12:30:34 CEST 2021


Module: kamailio
Branch: 5.5
Commit: b6428ca86c821ddf74fd4ea8a17aecdce39934f4
URL: https://github.com/kamailio/kamailio/commit/b6428ca86c821ddf74fd4ea8a17aecdce39934f4

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2021-06-10T12:27:02+02:00

dialog: safety checks for bind addr fields

- they can be null on non-local sockets
- GH #2757

(cherry picked from commit 490ae559d2b77b13b3f3831e7ff1aa58980e4086)

---

Modified: src/modules/dialog/dlg_db_handler.c

---

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

---

diff --git a/src/modules/dialog/dlg_db_handler.c b/src/modules/dialog/dlg_db_handler.c
index 1bfcb2cad7..b6a49da2a4 100644
--- a/src/modules/dialog/dlg_db_handler.c
+++ b/src/modules/dialog/dlg_db_handler.c
@@ -802,6 +802,7 @@ int update_dialog_dbinfo_unsafe(struct dlg_cell * cell)
 	int i;
 	struct dlg_var *var;
 	srjson_doc_t jdoc;
+	str sempty = str_init("");
 
 	db_val_t values[DIALOG_TABLE_COL_NO];
 
@@ -870,14 +871,25 @@ int update_dialog_dbinfo_unsafe(struct dlg_cell * cell)
 		SET_STR_VALUE(values+6, cell->tag[DLG_CALLEE_LEG]);
 		SET_PROPER_NULL_FLAG(cell->tag[DLG_CALLEE_LEG], values, 6);
 
-		LM_DBG("caller sock_info is %.*s, callee sock_info is %.*s\n",
-			cell->bind_addr[DLG_CALLER_LEG]->sock_str.len,
-			cell->bind_addr[DLG_CALLER_LEG]->sock_str.s,
-			cell->bind_addr[DLG_CALLEE_LEG]->sock_str.len,
-			cell->bind_addr[DLG_CALLEE_LEG]->sock_str.s);
 
-		SET_STR_VALUE(values+7, cell->bind_addr[DLG_CALLER_LEG]->sock_str);
-		SET_STR_VALUE(values+8, cell->bind_addr[DLG_CALLEE_LEG]->sock_str);
+		if(cell->bind_addr[DLG_CALLER_LEG]) {
+			LM_DBG("caller sock_info is %.*s\n",
+				cell->bind_addr[DLG_CALLER_LEG]->sock_str.len,
+				cell->bind_addr[DLG_CALLER_LEG]->sock_str.s);
+			SET_STR_VALUE(values+7, cell->bind_addr[DLG_CALLER_LEG]->sock_str);
+		} else {
+			LM_DBG("no caller sock_info\n");
+			SET_STR_VALUE(values+7, sempty);
+		}
+		if(cell->bind_addr[DLG_CALLEE_LEG]) {
+			LM_DBG("callee sock_info is %.*s\n",
+				cell->bind_addr[DLG_CALLEE_LEG]->sock_str.len,
+				cell->bind_addr[DLG_CALLEE_LEG]->sock_str.s);
+			SET_STR_VALUE(values+8, cell->bind_addr[DLG_CALLEE_LEG]->sock_str);
+		} else {
+			LM_DBG("no callee sock_info\n");
+			SET_STR_VALUE(values+8, sempty);
+		}
 
 		SET_STR_VALUE(values+12, cell->cseq[DLG_CALLER_LEG]);
 		SET_STR_VALUE(values+13, cell->cseq[DLG_CALLEE_LEG]);




More information about the sr-dev mailing list