Commit a7d0e609 authored by Robert Schmidt's avatar Robert Schmidt

config module: check that memory is enough, allow more restarts

A later commit implements the "restart" of the L1. The L1 reads
configuration options. First, allow to re-read configurations by
increasing the amount of memory the config module might allocate. Then,
avoid an out-of-bound write by checking that we still have memory
available (and assert if not possible).
parent 6330bfe0
......@@ -108,6 +108,7 @@ void *config_allocate_new(configmodule_interface_t *cfg, int sz, bool autoFree)
// add the memory piece in the managed memory pieces list
pthread_mutex_lock(&cfg->memBlocks_mutex);
int newBlockIdx=cfg->numptrs++;
AssertFatal(newBlockIdx < sizeofArray(cfg->oneBlock), "reached maximum number of dynamically allocatable blocks\n");
oneBlock_t* tmp=&cfg->oneBlock[newBlockIdx];
tmp->ptrs = (char *)ptr;
tmp->ptrsAllocated = true;
......
......@@ -41,7 +41,7 @@
#include "common/config/config_paramdesc.h"
#include "common/utils/T/T.h"
#define CONFIG_MAX_OOPT_PARAMS 10 // maximum number of parameters in the -O option (-O <cfgmode>:P1:P2...
#define CONFIG_MAX_ALLOCATEDPTRS 2048 // maximum number of parameters that can be dynamicaly allocated in the config module
#define CONFIG_MAX_ALLOCATEDPTRS 32768 // maximum number of parameters that can be dynamicaly allocated in the config module
/* default values for configuration module parameters */
#define CONFIG_LIBCONFIGFILE "libconfig" // use libconfig file
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment