Browse code

dialog: safety checks for bind addr fields

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

Daniel-Constantin Mierla authored on 03/06/2021 13:28:31
Showing 1 changed files
... ...
@@ -802,6 +802,7 @@ int update_dialog_dbinfo_unsafe(struct dlg_cell * cell)
802 802
 	int i;
803 803
 	struct dlg_var *var;
804 804
 	srjson_doc_t jdoc;
805
+	str sempty = str_init("");
805 806
 
806 807
 	db_val_t values[DIALOG_TABLE_COL_NO];
807 808
 
... ...
@@ -870,14 +871,25 @@ int update_dialog_dbinfo_unsafe(struct dlg_cell * cell)
870 871
 		SET_STR_VALUE(values+6, cell->tag[DLG_CALLEE_LEG]);
871 872
 		SET_PROPER_NULL_FLAG(cell->tag[DLG_CALLEE_LEG], values, 6);
872 873
 
873
-		LM_DBG("caller sock_info is %.*s, callee sock_info is %.*s\n",
874
-			cell->bind_addr[DLG_CALLER_LEG]->sock_str.len,
875
-			cell->bind_addr[DLG_CALLER_LEG]->sock_str.s,
876
-			cell->bind_addr[DLG_CALLEE_LEG]->sock_str.len,
877
-			cell->bind_addr[DLG_CALLEE_LEG]->sock_str.s);
878 874
 
879
-		SET_STR_VALUE(values+7, cell->bind_addr[DLG_CALLER_LEG]->sock_str);
880
-		SET_STR_VALUE(values+8, cell->bind_addr[DLG_CALLEE_LEG]->sock_str);
875
+		if(cell->bind_addr[DLG_CALLER_LEG]) {
876
+			LM_DBG("caller sock_info is %.*s\n",
877
+				cell->bind_addr[DLG_CALLER_LEG]->sock_str.len,
878
+				cell->bind_addr[DLG_CALLER_LEG]->sock_str.s);
879
+			SET_STR_VALUE(values+7, cell->bind_addr[DLG_CALLER_LEG]->sock_str);
880
+		} else {
881
+			LM_DBG("no caller sock_info\n");
882
+			SET_STR_VALUE(values+7, sempty);
883
+		}
884
+		if(cell->bind_addr[DLG_CALLEE_LEG]) {
885
+			LM_DBG("callee sock_info is %.*s\n",
886
+				cell->bind_addr[DLG_CALLEE_LEG]->sock_str.len,
887
+				cell->bind_addr[DLG_CALLEE_LEG]->sock_str.s);
888
+			SET_STR_VALUE(values+8, cell->bind_addr[DLG_CALLEE_LEG]->sock_str);
889
+		} else {
890
+			LM_DBG("no callee sock_info\n");
891
+			SET_STR_VALUE(values+8, sempty);
892
+		}
881 893
 
882 894
 		SET_STR_VALUE(values+12, cell->cseq[DLG_CALLER_LEG]);
883 895
 		SET_STR_VALUE(values+13, cell->cseq[DLG_CALLEE_LEG]);