/* Special workaround for luajit */
#if defined(WITH_LUAJIT) && !(defined(_X86_) || defined(__x86_64__) || defined(__i386__))
# define LPEG_LUD_WORKAROUND 1
-#endif
void * lpeg_allocate_mem_low(size_t sz);
void lpeg_free_mem_low(void *p);
+#endif
#endif
#include "lpvm.h"
#include "lpprint.h"
+#ifdef LPEG_LUD_WORKAROUND
#include <sys/mman.h>
#define MAX_PIECES (1u << 2u)
/* No match, unmapped by allocation */
}
+#endif
+
/* initial size for call/backtrack stack */
#if !defined(INITBACK)
#define INITBACK MAXBACK
#define COLOR_REJECT "#CB4B4B"
#define COLOR_TOTAL "#9440ED"
-const static ev_tstamp rrd_update_time = 1.0;
-const static guint64 rspamd_controller_ctx_magic = 0xf72697805e6941faULL;
+static const ev_tstamp rrd_update_time = 1.0;
+static const guint64 rspamd_controller_ctx_magic = 0xf72697805e6941faULL;
extern void fuzzy_stat_command (struct rspamd_task *task);
}
static inline void
-gamma (const uint8_t garlic, const uint8_t *salt,
- const uint8_t saltlen, uint8_t *r)
+catena_gamma (const uint8_t garlic, const uint8_t *salt,
+ const uint8_t saltlen, uint8_t *r)
{
const uint64_t q = UINT64_C(1) << ((3 * garlic + 3) / 4);
initmem (x, c, r);
/*Gamma Function*/
- gamma (garlic, salt, saltlen, r);
+ catena_gamma (garlic, salt, saltlen, r);
/* DBH */
for (k = 0; k < lambda; k++) {
struct rspamd_mime_text_part *part)
{
const gchar *p = begin, *c = begin;
- gchar last_c = '\0';
gboolean crlf_added = FALSE;
gboolean url_open_bracket = FALSE;
UChar32 uc;
case normal_char:
state = seen_cr;
if (p > c) {
- last_c = *(p - 1);
g_byte_array_append (part->utf_stripped_content,
(const guint8 *)c, p - c);
}
state = seen_lf;
if (p > c) {
- last_c = *(p - 1);
g_byte_array_append (part->utf_stripped_content,
(const guint8 *)c, p - c);
}
* - hostname ([ip]:port helo=xxx)
* Maybe more...
*/
- gboolean seen_ip_in_data = FALSE, seen_rdns_in_comment = FALSE;
+ gboolean seen_ip_in_data = FALSE;
if (rpart->head_comment && rpart->head_comment->dlen > 0) {
/* We can have info within comment as part of RFC */
- seen_rdns_in_comment = rspamd_smtp_received_process_host_tcpinfo (
+ rspamd_smtp_received_process_host_tcpinfo (
task, rh,
rpart->head_comment->data, rpart->head_comment->dlen);
}
struct rspamd_url **ptext_url)
{
struct rspamd_url *text_url;
- rspamd_ftok_t phished_tld, disp_tok, href_tok;
+ rspamd_ftok_t disp_tok, href_tok;
gint rc;
goffset url_pos;
gchar *url_str = NULL, *idn_hbuf;
if (!rspamd_url_is_subdomain (&disp_tok, &href_tok)) {
href_url->flags |= RSPAMD_URL_FLAG_PHISHED;
href_url->phished_url = text_url;
- phished_tld.begin = href_tok.begin;
- phished_tld.len = href_tok.len;
text_url->flags |= RSPAMD_URL_FLAG_HTML_DISPLAYED;
}
}
struct spf_addr *addr = NULL;
gboolean res = FALSE;
const gchar *begin;
- struct rspamd_task *task;
gchar t;
g_assert (elt != NULL);
return TRUE;
}
- task = rec->task;
begin = expand_spf_macro (rec, resolved, elt);
addr = rspamd_spf_new_addr (rec, resolved, begin);
g_assert (addr != NULL);
GPtrArray *sorted_symbols;
struct rspamd_action *act;
struct rspamd_symbols_group *gr;
- gdouble gr_score;
guint i, j;
khiter_t k;
symbuf = rspamd_fstring_sized_new (128);
sorted_symbols = g_ptr_array_sized_new (kh_size (mres->sym_groups));
- kh_foreach (mres->sym_groups, gr, gr_score,{
+ kh_foreach_key (mres->sym_groups, gr,{
if (!(gr->flags & RSPAMD_SYMBOL_GROUP_PUBLIC)) {
if (lf->type == RSPAMD_LOG_PUBLIC_GROUPS) {
continue;
rspamd_http_keepalive_handler (gint fd, short what, gpointer ud)
{
struct rspamd_http_keepalive_cbdata *cbdata =
- (struct rspamd_http_keepalive_cbdata *)ud;
- struct rspamd_http_context *ctx;
- /*
+ (struct rspamd_http_keepalive_cbdata *)ud;/*
* We can get here if a remote side reported something or it has
* timed out. In both cases we just terminate keepalive connection.
*/
- ctx = cbdata->ctx;
g_queue_delete_link (cbdata->queue, cbdata->link);
msg_debug_http_context ("remove keepalive element %s (%s), %d connections left",
rspamd_inet_address_to_string_pretty (cbdata->conn->keepalive_hash_key->addr),
{
gchar datebuf[128];
struct rspamd_http_message *msg;
- struct rspamd_map *map;
- map = cbd->map;
msg = rspamd_http_new_message (HTTP_REQUEST);
if (cbd->bk->protocol == MAP_PROTO_HTTPS) {
{
gchar zero, numbuf[G_ASCII_DTOSTR_BUF_SIZE], dtoabuf[32], *p, *last;
guchar c;
- const gchar *buf_start = fmt, *fmt_start = NULL;
+ const gchar *buf_start = fmt;
gint d;
gdouble f;
glong written = 0, wr, slen;
written += wr;
}
- fmt_start = fmt;
-
i64 = 0;
ui64 = 0;
gpointer handler_data)
{
gint ret;
- short what;
g_assert (conn != NULL);
if (ret == SSL_ERROR_WANT_READ) {
msg_debug_ssl ("not connected, want read");
- what = EV_READ;
}
else if (ret == SSL_ERROR_WANT_WRITE) {
msg_debug_ssl ("not connected, want write");
- what = EV_WRITE;
}
else {
conn->shut = ssl_shut_unclean;
#ifndef HAVE_SETPROCTITLE
#ifdef LINUX
-static gchar *title_buffer = 0;
+static gchar *title_buffer = NULL;
static size_t title_buffer_size = 0;
static gchar *title_progname, *title_progname_full;
#endif
ssize_t written;
if (fmt) {
- ssize_t written2;
va_list ap;
written = rspamd_snprintf (title_buffer,
return -1;
va_start (ap, fmt);
- written2 = rspamd_vsnprintf (title_buffer + written,
+ rspamd_vsnprintf (title_buffer + written,
title_buffer_size - written,
fmt,
ap);
va_end (ap);
- if (written2 < 0 || (size_t) written2 >= title_buffer_size - written)
- return -1;
}
else {
written = rspamd_snprintf (title_buffer,
{
const gchar *old_path, *additional_path = NULL;
const ucl_object_t *opts = NULL;
- const gchar *pluginsdir = RSPAMD_PLUGINSDIR,
- *rulesdir = RSPAMD_RULESDIR,
+ const gchar *rulesdir = RSPAMD_RULESDIR,
*lualibdir = RSPAMD_LUALIBDIR,
- *libdir = RSPAMD_LIBDIR,
- *sharedir = RSPAMD_SHAREDIR;
+ *libdir = RSPAMD_LIBDIR;
const gchar *t;
gchar path_buf[PATH_MAX];
}
else {
/* Try environment */
- t = getenv ("SHAREDIR");
- if (t) {
- sharedir = t;
- }
-
- t = getenv ("PLUGINSDIR");
- if (t) {
- pluginsdir = t;
- }
-
t = getenv ("RULESDIR");
if (t) {
rulesdir = t;
}
if (vars) {
- t = g_hash_table_lookup (vars, "PLUGINSDIR");
- if (t) {
- pluginsdir = t;
- }
-
- t = g_hash_table_lookup (vars, "SHAREDIR");
- if (t) {
- sharedir = t;
- }
-
t = g_hash_table_lookup (vars, "RULESDIR");
if (t) {
rulesdir = t;
/* Process private key */
rc = i2d_RSAPrivateKey_bio (mbio, r);
+
+ if (rc == 0) {
+ BIO_free (mbio);
+ BN_free (e);
+ RSA_free (r);
+ EVP_PKEY_free (pk);
+
+ return luaL_error (L, "i2d_RSAPrivateKey_bio failed");
+ }
+
len = BIO_get_mem_data (mbio, &data);
b64_data = rspamd_encode_base64 (data, len, -1, &b64_len);
/* Process public key */
BIO_reset (mbio);
rc = i2d_RSA_PUBKEY_bio (mbio, r);
+
+ if (rc == 0) {
+ BIO_free (mbio);
+ BN_free (e);
+ RSA_free (r);
+ EVP_PKEY_free (pk);
+
+ return luaL_error (L, "i2d_RSA_PUBKEY_bio failed");
+ }
+
len = BIO_get_mem_data (mbio, &data);
b64_data = rspamd_encode_base64 (data, len, -1, &b64_len);
}
lua_pushboolean (L, ret);
+ (void)nrcpt; /* Silence warning */
return 1;
}
{
LUA_TRACE_POINT;
struct rspamd_task *task = lua_check_task (L, 1);
- struct rspamd_scan_result *metric_res;
struct rspamd_action *action;
if (task) {
- metric_res = task->result;
-
action = rspamd_check_action_metric (task);
lua_pushstring (L, action->name);
}
lua_udp_io_handler (gint fd, short what, gpointer p)
{
struct lua_udp_cbdata *cbd = (struct lua_udp_cbdata *)p;
- lua_State *L;
gssize r;
- L = cbd->L;
-
if (what == EV_TIMEOUT) {
if (cbd->sent && cbd->retransmits > 0) {
r = lua_try_send_request (cbd);
struct rspamd_control_reply rep;
struct rspamd_control_cbdata *cbd = (struct rspamd_control_cbdata *)ud;
rspamd_mempool_t *pool;
- lua_State *L;
- L = cbd->L;
pool = cbd->pool;
memset (&rep, 0, sizeof (rep));
rspamd_mempool_set_variable (task->task_pool, "dkim-signature",
sigs, dkim_module_free_list);
} else {
- (void) g_list_append (sigs, hdr);
+ sigs = g_list_append (sigs, hdr);
+ (void)sigs;
}
}
struct regexp_module_item *cur_item = NULL;
const ucl_object_t *sec, *value, *elt;
ucl_object_iter_t it = NULL;
- gint res = TRUE, id, nre = 0, nlua = 0, nshots = cfg->default_max_shots;
+ gint res = TRUE, nre = 0, nlua = 0, nshots = cfg->default_max_shots;
if (!rspamd_config_is_module_enabled (cfg, "regexp")) {
return TRUE;
}
}
- id = rspamd_symcache_add_symbol (cfg->cache,
+ rspamd_symcache_add_symbol (cfg->cache,
cur_item->symbol,
0,
process_regexp_item,
* 3 - line num (int), always 1...
* 4 - column num (must be less than size)
*/
- const gchar *what, *text;
+ const gchar *what;
gsize column, tlen, cur_top, elt_pos;
ReplxxColor elt_color = REPLXX_COLOR_DEFAULT;
lua_rawgeti (L, elt_pos, 1);
what = lua_tostring (L, -1);
lua_rawgeti (L, elt_pos, 2);
- text = lua_tolstring (L, -1, &tlen);
+ lua_tolstring (L, -1, &tlen);
lua_rawgeti (L, elt_pos, 4);
column = lua_tointeger (L, -1);
GString *tb;
gint err_idx, i;
lua_State *L;
- struct rspamadm_lua_repl_context *ctx;
- struct rspamadm_lua_repl_session *session = conn_ent->ud;
ucl_object_t *obj, *elt;
const gchar *body;
gsize body_len;
-
- ctx = session->ctx;
-
struct thread_entry *thread = lua_thread_pool_get_for_config (rspamd_main->cfg);
+
L = thread->lua_state;
body = rspamd_http_message_get_body (msg, &body_len);