[sr-dev] git:master:69c004ee: core: modparam - safety check for str s pointer

Daniel-Constantin Mierla miconda at gmail.com
Fri Apr 29 14:05:06 CEST 2022


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2022-04-29T14:04:12+02:00

core: modparam - safety check for str s pointer

- deal with the case of argument with 'nonnull' attribute passed null

---

Modified: src/core/modparam.c

---

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

---

diff --git a/src/core/modparam.c b/src/core/modparam.c
index 361536691d..0ccecf7c90 100644
--- a/src/core/modparam.c
+++ b/src/core/modparam.c
@@ -147,6 +147,12 @@ int set_mod_param_regex(char* regex, char* name, modparam_t type, void* val)
 							break;
 
 						case PARAM_STR:
+							if( ((str*)val2)->s==NULL) {
+								LM_ERR("null value\n");
+								regfree(&preg);
+								pkg_free(reg);
+								return -1;
+							}
 							((str*)ptr)->s = pkg_malloc(((str*)val2)->len+1);
 							if (!((str*)ptr)->s) {
 								PKG_MEM_ERROR;




More information about the sr-dev mailing list