[sr-dev] git:master:2cebd46f: dialog: remove strlen() checks when setting a variable

Daniel-Constantin Mierla miconda at gmail.com
Thu Sep 1 10:55:36 CEST 2022


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2022-09-01T10:53:54+02:00

dialog: remove strlen() checks when setting a variable

- assumed key->s and val->s are 0-terminated, which may not be the case

---

Modified: src/modules/dialog/dlg_var.c

---

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

---

diff --git a/src/modules/dialog/dlg_var.c b/src/modules/dialog/dlg_var.c
index 6c4da06742..ef73c022d0 100644
--- a/src/modules/dialog/dlg_var.c
+++ b/src/modules/dialog/dlg_var.c
@@ -352,7 +352,7 @@ int get_dlg_variable_uintval(struct dlg_cell *dlg, str *key, unsigned int *uval)
 int set_dlg_variable(struct dlg_cell *dlg, str *key, str *val)
 {
     int ret = -1;
-    if( !dlg || !key || key->len > strlen(key->s) || (val && val->len > strlen(val->s)))
+    if( !dlg || !key || !key->s || key->len<=0 )
     {
         LM_ERR("BUG - bad parameters\n");
         return -1;




More information about the sr-dev mailing list