[sr-dev] git:master:c3b2eacb: core: Fix the cfg framework variable input type default

Mancaș George mancas.f.george at gmail.com
Mon Aug 12 11:37:15 CEST 2019


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

Author: Mancaș George <mancas.f.george at gmail.com>
Committer: Mancaș George <mancas.f.george at gmail.com>
Date: 2019-08-01T09:39:28Z

core: Fix the cfg framework variable input type default

What the affected line of code really wants to achieve is: if an
accepted inputs type mask is not specified then default to accepting
only the actual variable type. So we must mask the var type first,
then shift it by `CFG_INPUT_SHIFT`, before or-ing it with the rest.

What happened before was that the entire type was shifted, and that
included var type, input type and flags. What we end up with is some
additional higher bits set (for flags). I actually discovered this while
adding an additional flag that was meant to mark variables as private,
only accessible through an internal API (not available to modules such
as cfg_rpc).

---

Modified: src/core/cfg/cfg.c

---

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

---

diff --git a/src/core/cfg/cfg.c b/src/core/cfg/cfg.c
index 3822a9c94d..488d72f35a 100644
--- a/src/core/cfg/cfg.c
+++ b/src/core/cfg/cfg.c
@@ -94,7 +94,7 @@ int cfg_declare(char *group_name, cfg_def_t *def, void *values, int def_size,
 
 		/* verify the type of the input */
 		if (CFG_INPUT_MASK(def[i].type)==0) {
-			def[i].type |= def[i].type << CFG_INPUT_SHIFT;
+			def[i].type |= CFG_VAR_MASK(def[i].type) << CFG_INPUT_SHIFT;
 		} else {
 			if ((CFG_INPUT_MASK(def[i].type) != CFG_VAR_MASK(def[i].type) << CFG_INPUT_SHIFT)
 			&& (def[i].on_change_cb == 0)) {




More information about the sr-dev mailing list