Module: kamailio
Branch: 5.4
Commit: 465fbace1586874b60b98ab04caddd1c76b2810c
URL:
https://github.com/kamailio/kamailio/commit/465fbace1586874b60b98ab04caddd1…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-07-29T10:44:19+02:00
dialog: safety checks for bind addr fields
- they can be null on non-local sockets
- GH #2757
(cherry picked from commit 490ae559d2b77b13b3f3831e7ff1aa58980e4086)
(cherry picked from commit b6428ca86c821ddf74fd4ea8a17aecdce39934f4)
---
Modified: src/modules/dialog/dlg_db_handler.c
---
Diff:
https://github.com/kamailio/kamailio/commit/465fbace1586874b60b98ab04caddd1…
Patch:
https://github.com/kamailio/kamailio/commit/465fbace1586874b60b98ab04caddd1…
---
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]);