Browse code

core: modparam - safety check for str s pointer

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

(cherry picked from commit 69c004eec161c14d957f9e4011aeff4163af858d)

Daniel-Constantin Mierla authored on 29/04/2022 12:04:12
Showing 1 changed files
... ...
@@ -147,6 +147,12 @@ int set_mod_param_regex(char* regex, char* name, modparam_t type, void* val)
147 147
 							break;
148 148
 
149 149
 						case PARAM_STR:
150
+							if( ((str*)val2)->s==NULL) {
151
+								LM_ERR("null value\n");
152
+								regfree(&preg);
153
+								pkg_free(reg);
154
+								return -1;
155
+							}
150 156
 							((str*)ptr)->s = pkg_malloc(((str*)val2)->len+1);
151 157
 							if (!((str*)ptr)->s) {
152 158
 								PKG_MEM_ERROR;