#define GET_VAR(prefix,name) \
snprintf(varname, sizeof(varname), "%s.%s", (prefix), (name))
+static void THashConfigValidate(const char *confvalue, const char *varname)
+{
+ for (size_t i = 0; i < strlen(confvalue); i++) {
+ if (!isdigit(confvalue[i])) {
+ FatalError(SC_ERR_SIZE_PARSE, "Error parsing %s "
+ "from key %s. Killing Engine",
+ confvalue, varname);
+ }
+ }
+}
+
/** \brief initialize the configuration
* \warning Not thread safe */
static void THashInitConfig(THashTableContext *ctx, const char *cnf_prefix)
GET_VAR(cnf_prefix, "hash-size");
if ((ConfGet(varname, &conf_val)) == 1)
{
+ /* validate hash-size value is a numerical value */
+ THashConfigValidate(conf_val, varname);
+
if (ByteExtractStringUint32(&configval, 10, strlen(conf_val),
conf_val) > 0) {
ctx->config.hash_size = configval;
GET_VAR(cnf_prefix, "prealloc");
if ((ConfGet(varname, &conf_val)) == 1)
{
+ /* validate prealloc value is a numerical value */
+ THashConfigValidate(conf_val, varname);
+
if (ByteExtractStringUint32(&configval, 10, strlen(conf_val),
conf_val) > 0) {
ctx->config.prealloc = configval;