k = 0;
/* Create window */
- step = (rrd_result->rra_rows / desired_points + 0.5);
+ step = ceil (((gdouble)rrd_result->rra_rows) / desired_points);
g_assert (step >= 1);
acc = g_malloc0 (sizeof (double) * rrd_result->ds_count * step);
}
parser = ucl_parser_new (0);
- ucl_parser_add_chunk (parser, msg->body_buf.begin, msg->body_buf.len);
+ if (!ucl_parser_add_chunk (parser, msg->body_buf.begin, msg->body_buf.len)) {
+ if ((error = ucl_parser_get_error (parser)) != NULL) {
+ msg_err_session ("cannot parse input: %s", error);
+ rspamd_controller_send_error (conn_ent, 400, "Cannot parse input");
+ ucl_parser_free (parser);
+ return 0;
+ }
- if ((error = ucl_parser_get_error (parser)) != NULL) {
- msg_err_session ("cannot parse input: %s", error);
+ msg_err_session ("cannot parse input: unknown error");
rspamd_controller_send_error (conn_ent, 400, "Cannot parse input");
ucl_parser_free (parser);
return 0;
}
+
+
obj = ucl_parser_get_object (parser);
ucl_parser_free (parser);
}
parser = ucl_parser_new (0);
- ucl_parser_add_chunk (parser, msg->body_buf.begin, msg->body_buf.len);
+ if (!ucl_parser_add_chunk (parser, msg->body_buf.begin, msg->body_buf.len)) {
+ if ((error = ucl_parser_get_error (parser)) != NULL) {
+ msg_err_session ("cannot parse input: %s", error);
+ rspamd_controller_send_error (conn_ent, 400, "Cannot parse input");
+ ucl_parser_free (parser);
+ return 0;
+ }
- if ((error = ucl_parser_get_error (parser)) != NULL) {
- msg_err_session ("cannot parse input: %s", error);
+ msg_err_session ("cannot parse input: unknown error");
rspamd_controller_send_error (conn_ent, 400, "Cannot parse input");
ucl_parser_free (parser);
return 0;
*/
p = rspamd_http_message_get_body (msg, &remain);
- if (remain > sizeof (gint32) * 2) {
+ if (p && remain > sizeof (gint32) * 2) {
memcpy (&revision, p, sizeof (gint32));
revision = GINT32_TO_LE (revision);
if (!rspamd_http_message_get_body (msg, NULL) || !msg->url
|| msg->url->len == 0) {
msg_err_fuzzy_update ("empty update message, not processing");
+ err_str = "Empty update";
goto end;
}
return TRUE;
err:
+ g_free (up->name);
+ rspamd_upstreams_destroy (up->u);
- if (up) {
- g_free (up->name);
- rspamd_upstreams_destroy (up->u);
-
- if (up->key) {
- rspamd_pubkey_unref (up->key);
- }
-
- g_slice_free1 (sizeof (*up), up);
+ if (up->key) {
+ rspamd_pubkey_unref (up->key);
}
+ g_slice_free1 (sizeof (*up), up);
+
return FALSE;
}
msg_debug_task ("rar archive is invalid (bad int32)"); \
return; \
} \
- n = p[0] + (p[1] << 8) + (p[2] << 16) + (p[3] << 24); \
+ n = (guint)p[0] + ((guint)p[1] << 8) + ((guint)p[2] << 16) + ((guint)p[3] << 24); \
p += sizeof (guint32); \
} while (0)
nparam->name.len = name_end - name_start;
decoded = rspamd_mime_header_decode (pool, value_start, value_end - value_start);
RSPAMD_FTOK_FROM_STR (&nparam->value, decoded);
- DL_APPEND (found, nparam);
if (!found) {
g_hash_table_insert (cd->attrs, &nparam->name, nparam);
}
+ DL_APPEND (found, nparam);
+
srch.begin = "filename";
srch.len = 8;
rspamd_images_process (task);
rspamd_archives_process (task);
- if (task->received && task->received->len > 0) {
+ if (task->received->len > 0) {
gboolean need_recv_correction = FALSE;
rspamd_inet_addr_t *raddr;
if (cfg == NULL || cfg->nameservers == NULL) {
/* Parse resolv.conf */
if (!rdns_resolver_parse_resolv_conf (dns_resolver->r, "/etc/resolv.conf")) {
- msg_err_config (
- "cannot parse resolv.conf and no nameservers defined, so no ways to resolve addresses");
+ msg_err ("cannot parse resolv.conf and no nameservers defined, "
+ "so no ways to resolve addresses");
rdns_resolver_release (dns_resolver->r);
dns_resolver->r = NULL;
g_assert (ctx != NULL);
stcf = ctx->stcf;
- if (task) {
- L = task->cfg->lua_state;
- }
+ L = task->cfg->lua_state;
if (ctx->enable_users) {
if (ctx->cbref_user == -1) {
p += 3;
for (;;) {
- if (mask > 32) {
+ if (mask >= 32) {
mask -= 32;
*p = 0;
}
g_slice_free1 (sizeof (*hdata), hdata);
}
- if (fdata) {
- g_slice_free1 (sizeof (*fdata), fdata);
- }
-
return NULL;
}
return FALSE;
}
if (nanosleep (&sleep_ts, NULL) == -1 && errno != EINTR) {
- close (fd);
msg_err_pool_check ("cannot sleep open lock file %s: %s", lock,
strerror (errno));
}
}
else {
+ if (map != NULL) {
+ munmap (map, len);
+ }
+
return luaL_error (L, "invalid arguments");
}
fann_type *inp, *outp;
guint i;
+ g_assert (num_data > 0 && num_input > 0 && num_output > 0);
+
t = calloc (1, sizeof (*t));
g_assert (t != NULL);
guint i;
if (hc != NULL) {
- lua_createtable (L, hc->blocks->len, 0);
-
if (hc->blocks && hc->blocks->len > 0) {
+ lua_createtable (L, hc->blocks->len, 0);
+
for (i = 0; i < hc->blocks->len; i ++) {
bl = g_ptr_array_index (hc->blocks, i);
lua_html_push_block (L, bl);
lua_pop (cbdata->L, 1);
}
}
-
- cbdata->data = rspamd_fstring_assign (cbdata->data, "", 0);
+ else if (cbdata->data != NULL) {
+ cbdata->data = rspamd_fstring_assign (cbdata->data, "", 0);
+ }
}
gint
if (lua_istable (L, 1)) {
/* Table version */
+ lua_pushvalue (L, 1);
lua_pushstring (L, "task");
lua_gettable (L, -2);
if (lua_type (L, -1) == LUA_TUSERDATA) {
dbname = lua_tostring (L, -1);
}
lua_pop (L, 1);
+ lua_pop (L, 1); /* table */
if (ret && addr != NULL) {
redisReply *r;
if (lua_istable (L, 1)) {
+ lua_pushvalue (L, 1);
lua_pushstring (L, "cmd");
lua_gettable (L, -2);
}
lua_pop (L, 1);
- lua_pushstring (L, "args");
- lua_gettable (L, -2);
- lua_redis_parse_args (L, -1, cmd, &args, &arglens, &nargs);
+ if (cmd) {
+ lua_pushstring (L, "args");
+ lua_gettable (L, -2);
+ lua_redis_parse_args (L, -1, cmd, &args, &arglens, &nargs);
+ lua_pop (L, 1);
+ }
+
lua_pop (L, 1);
if (addr && cmd) {
struct lua_redis_userdata *ud;
struct lua_redis_ctx *ctx, **pctx;
gdouble timeout = REDIS_DEFAULT_TIMEOUT;
- gboolean ret = FALSE;
ctx = rspamd_lua_redis_prepare_connection (L, NULL);
ud = &ctx->d.async;
lua_pushstring (L, "timeout");
- lua_gettable (L, -2);
+ lua_gettable (L, 1);
if (lua_type (L, -1) == LUA_TNUMBER) {
timeout = lua_tonumber (L, -1);
}
+
lua_pop (L, 1);
ud->timeout = timeout;
}
return 2;
}
- if (ret) {
- pctx = lua_newuserdata (L, sizeof (ctx));
- *pctx = ctx;
- rspamd_lua_setclass (L, "rspamd{redis}", -1);
- }
- else {
- lua_pushnil (L);
- }
+ pctx = lua_newuserdata (L, sizeof (ctx));
+ *pctx = ctx;
+ rspamd_lua_setclass (L, "rspamd{redis}", -1);
return 1;
}
gsize len, i;
gboolean found = FALSE;
- if (trie) {
+ if (trie && task) {
for (i = 0; i < task->text_parts->len; i ++) {
part = g_ptr_array_index (task->text_parts, i);
gsize len;
gboolean found = FALSE;
- if (trie) {
+ if (trie && task) {
text = task->msg.begin;
len = task->msg.len;
gsize len;
gboolean found = FALSE;
- if (trie) {
+ if (trie && task) {
if (task->raw_headers_content.len > 0) {
text = task->msg.begin + task->raw_headers_content.len;
len = task->msg.len - task->raw_headers_content.len;