if ((ConfGetInt("pcap.buffer-size", &value)) == 1) {
if (value >= 0 && value <= INT_MAX) {
SCLogInfo("Pcap will use %d buffer size", (int)value);
- aconf->buffer_size = value;
+ aconf->buffer_size = (int)value;
} else {
SCLogWarning("pcap.buffer-size "
"value of %" PRIiMAX " is invalid. Valid range is "
aconf->snaplen = 0;
if (ConfGetChildValueIntWithDefault(if_root, if_default, "snaplen", &snaplen) != 1) {
SCLogDebug("could not get snaplen or none specified");
+ } else if (snaplen < INT_MIN || snaplen > INT_MAX) {
+ SCLogDebug("snaplen value is not in the accepted range");
} else {
- aconf->snaplen = snaplen;
+ aconf->snaplen = (int)snaplen;
}
return aconf;
}
}
+static bool JsonU32Value(json_t *jarg, uint32_t *ret)
+{
+ int64_t r = json_integer_value(jarg);
+ if (r < 0 || r > UINT32_MAX) {
+ return false;
+ }
+ *ret = (uint32_t)r;
+ return true;
+}
+
/**
* \brief Command to add a tenant handler
*
json_object_set_new(answer, "message", json_string("id is not an integer"));
return TM_ECODE_FAILED;
}
- uint32_t tenant_id = json_integer_value(jarg);
+ uint32_t tenant_id;
+ if (!JsonU32Value(jarg, &tenant_id)) {
+ SCLogInfo("tenant_id is not a uint32");
+ json_object_set_new(answer, "message", json_string("tenant_id is not a uint32"));
+ return TM_ECODE_FAILED;
+ }
/* 2 get tenant handler type */
jarg = json_object_get(cmd, "htype");
json_object_set_new(answer, "message", json_string("id is not an integer"));
return TM_ECODE_FAILED;
}
- uint32_t tenant_id = json_integer_value(jarg);
+ uint32_t tenant_id;
+ if (!JsonU32Value(jarg, &tenant_id)) {
+ SCLogInfo("tenant_id is not a uint32");
+ json_object_set_new(answer, "message", json_string("tenant_id is not a uint32"));
+ return TM_ECODE_FAILED;
+ }
/* 2 get tenant handler type */
jarg = json_object_get(cmd, "htype");
json_object_set_new(answer, "message", json_string("id is not an integer"));
return TM_ECODE_FAILED;
}
- uint32_t tenant_id = json_integer_value(jarg);
+ uint32_t tenant_id;
+ if (!JsonU32Value(jarg, &tenant_id)) {
+ SCLogInfo("tenant_id is not a uint32");
+ json_object_set_new(answer, "message", json_string("tenant_id is not a uint32"));
+ return TM_ECODE_FAILED;
+ }
/* 2 get tenant yaml */
jarg = json_object_get(cmd, "filename");
json_object_set_new(answer, "message", json_string("id is not an integer"));
return TM_ECODE_FAILED;
}
- uint32_t tenant_id = json_integer_value(jarg);
+ uint32_t tenant_id;
+ if (!JsonU32Value(jarg, &tenant_id)) {
+ SCLogInfo("tenant_id is not a uint32");
+ json_object_set_new(answer, "message", json_string("tenant_id is not a uint32"));
+ return TM_ECODE_FAILED;
+ }
/* 2 get tenant yaml */
jarg = json_object_get(cmd, "filename");
json_object_set_new(answer, "message", json_string("id is not an integer"));
return TM_ECODE_FAILED;
}
- uint32_t tenant_id = json_integer_value(jarg);
+ uint32_t tenant_id;
+ if (!JsonU32Value(jarg, &tenant_id)) {
+ SCLogInfo("tenant_id is not a uint32");
+ json_object_set_new(answer, "message", json_string("tenant_id is not a uint32"));
+ return TM_ECODE_FAILED;
+ }
SCLogInfo("remove-tenant: removing tenant %d", tenant_id);
json_object_set_new(answer, "message", json_string("expire is not an integer"));
return TM_ECODE_FAILED;
}
- uint32_t expire = json_integer_value(jarg);
+ uint32_t expire;
+ if (!JsonU32Value(jarg, &expire)) {
+ SCLogInfo("expire is not a uint32");
+ json_object_set_new(answer, "message", json_string("expire is not a uint32"));
+ return TM_ECODE_FAILED;
+ }
SCLogInfo("add-hostbit: ip %s hostbit %s expire %us", ipaddress, hostbit, expire);
SCTime_t current_time = TimeGet();
Host *host = HostGetHostFromHash(&a);
if (host) {
- HostBitSet(host, idx, SCTIME_SECS(current_time) + expire);
+ if (SCTIME_SECS(current_time) + expire > UINT32_MAX) {
+ json_object_set_new(answer, "message", json_string("couldn't set host expire"));
+ HostRelease(host);
+ return TM_ECODE_FAILED;
+ }
+ HostBitSet(host, idx, (uint32_t)(SCTIME_SECS(current_time) + expire));
HostRelease(host);
json_object_set_new(answer, "message", json_string("hostbit added"));