Browse code

core: cfg ctx - checks for valid variable offset

(cherry picked from commit 303be6a94be40dbe7c26c96e768627e8e9d0f860)

Daniel-Constantin Mierla authored on 09/04/2021 14:23:28
Showing 1 changed files
... ...
@@ -284,7 +284,11 @@ static int cfg_update_defaults(cfg_group_meta_t	*meta,
284 284
 				meta->array = array;
285 285
 				clone_done = 1;
286 286
 			}
287
-			memcpy(ginst->vars + var->offset, new_val, cfg_var_size(var));
287
+			if(ginst->vars + var->offset) {
288
+				memcpy(ginst->vars + var->offset, new_val, cfg_var_size(var));
289
+			} else {
290
+				LM_ERR("invalid variable offset\n");
291
+			}
288 292
 		}
289 293
 	}
290 294
 	return 0;
... ...
@@ -1122,6 +1126,10 @@ int cfg_commit(cfg_ctx_t *ctx)
1122 1126
 			}
1123 1127
 			p = group_inst->vars + changed->var->offset;
1124 1128
 		}
1129
+		if(p==NULL) {
1130
+			LM_ERR("failed to resolve valid variable offset\n");
1131
+			goto error;
1132
+		}
1125 1133
 
1126 1134
 		if (((changed->group_id_set && !changed->del_value
1127 1135
 						&& CFG_VAR_TEST_AND_SET(group_inst, changed->var))