@@ -30,14 +30,6 @@ | |||
#include "upstream.h" | |||
#include "ref.h" | |||
static const unsigned base = 36; | |||
static const unsigned t_min = 1; | |||
static const unsigned t_max = 26; | |||
static const unsigned skew = 38; | |||
static const unsigned damp = 700; | |||
static const unsigned initial_n = 128; | |||
static const unsigned initial_bias = 72; | |||
static const int dns_port = 53; | |||
static const int default_io_cnt = 8; | |||
@@ -33,7 +33,13 @@ | |||
*/ | |||
#include "dns_private.h" | |||
static const unsigned base = 36; | |||
static const unsigned t_min = 1; | |||
static const unsigned t_max = 26; | |||
static const unsigned skew = 38; | |||
static const unsigned damp = 700; | |||
static const unsigned initial_n = 128; | |||
static const unsigned initial_bias = 72; | |||
/* Punycode utility */ | |||
static unsigned int | |||
digit (unsigned n) |
@@ -676,7 +676,7 @@ rspamd_cryptobox_encrypt_update (void *enc_ctx, const guchar *in, gsize inlen, | |||
EVP_CIPHER_CTX *s = enc_ctx; | |||
gint r; | |||
r = outlen ? *outlen : inlen; | |||
r = inlen; | |||
g_assert (EVP_EncryptUpdate (s, out, &r, in, inlen) == 1); | |||
if (outlen) { |
@@ -1518,7 +1518,7 @@ rspamd_dkim_canonize_header_simple (rspamd_dkim_context_t *ctx, | |||
if (elt && elt->append_crlf) { | |||
rspamd_dkim_signature_update (ctx, elt->begin, elt->len + 1); | |||
} | |||
else { | |||
else if (elt) { | |||
rspamd_dkim_signature_update (ctx, elt->begin, elt->len); | |||
} | |||
} |
@@ -476,6 +476,7 @@ rspamd_ast_priority_cmp (GNode *a, GNode *b) | |||
struct rspamd_expression_elt *ea = a->data, *eb = b->data; | |||
gdouble w1, w2; | |||
/* Special logic for atoms */ | |||
if (ea->type == ELT_ATOM && eb->type == ELT_ATOM && | |||
ea->priority == eb->priority) { | |||
@@ -495,8 +496,18 @@ rspamd_ast_priority_cmp (GNode *a, GNode *b) | |||
static gboolean | |||
rspamd_ast_resort_traverse (GNode *node, gpointer unused) | |||
{ | |||
GNode *children, *last; | |||
if (node->children) { | |||
children = node->children; | |||
last = g_node_last_sibling (children); | |||
/* Needed for utlist compatibility */ | |||
children->prev = last; | |||
DL_SORT (node->children, rspamd_ast_priority_cmp); | |||
/* Restore GLIB compatibility */ | |||
children = node->children; | |||
children->prev = NULL; | |||
} | |||
return FALSE; |
@@ -469,13 +469,13 @@ rspamd_encode_base32_buf (const guchar *in, gsize inlen, gchar *out, | |||
{ | |||
static const char b32[]="ybndrfg8ejkmcpqxot1uwisza345h769"; | |||
gchar *o, *end; | |||
gsize i, r; | |||
gsize i; | |||
gint remain = -1, x; | |||
end = out + outlen; | |||
o = out; | |||
for (i = 0, r = 0; i < inlen && o < end - 1; i++) { | |||
for (i = 0; i < inlen && o < end - 1; i++) { | |||
switch (i % 5) { | |||
case 0: | |||
/* 8 bits of input and 3 to remain */ |
@@ -727,7 +727,7 @@ rspamd_upstream_get_round_robin (struct upstream_list *ups, gboolean use_cur) | |||
} | |||
} | |||
if (use_cur) { | |||
if (use_cur && selected) { | |||
if (selected->cur_weight > 0) { | |||
selected->cur_weight--; | |||
} | |||
@@ -735,6 +735,7 @@ rspamd_upstream_get_round_robin (struct upstream_list *ups, gboolean use_cur) | |||
selected->cur_weight = selected->weight; | |||
} | |||
} | |||
rspamd_mutex_unlock (ups->lock); | |||
return selected; |
@@ -1153,12 +1153,6 @@ resolve_stat_filename (rspamd_mempool_t * pool, | |||
s += rcptlen; | |||
continue; | |||
} | |||
else if (*c == '%' && *(c + 1) == 'r') { | |||
c += 2; | |||
memcpy (s, from, fromlen); | |||
s += fromlen; | |||
continue; | |||
} | |||
*s++ = *c; | |||
} | |||
@@ -85,6 +85,10 @@ lua_cdb_get_name (lua_State *L) | |||
{ | |||
struct cdb *cdb = lua_check_cdb (L); | |||
if (!cdb) { | |||
lua_error (L); | |||
return 1; | |||
} | |||
lua_pushstring (L, cdb->filename); | |||
return 1; | |||
} | |||
@@ -98,6 +102,10 @@ lua_cdb_lookup (lua_State *L) | |||
gsize vlen; | |||
gint64 vpos; | |||
if (!cdb) { | |||
lua_error (L); | |||
return 1; | |||
} | |||
/* | |||
* XXX: this code is placed here because event_loop is called inside workers, so start | |||
* monitoring on first check, not on creation |
@@ -933,6 +933,12 @@ lua_redis_exec (lua_State *L) | |||
gint ret; | |||
guint i, nret = 0; | |||
if (ctx == NULL) { | |||
lua_error (L); | |||
return 1; | |||
} | |||
if (ctx->async) { | |||
lua_pushstring (L, "Async redis pipelining is not implemented"); | |||
lua_error (L); |