summaryrefslogtreecommitdiffstats
path: root/src/fuzzy_storage.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-06-27 14:13:42 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-06-27 14:13:42 +0100
commit0b2882ea9b6722a6ca9533e9121a5f30bd55fc49 (patch)
treead50666cca2d9f3fed19d427483bf05f9307a43a /src/fuzzy_storage.c
parent92eb411cf4c7e2fab21039d0e43b93e66a789842 (diff)
downloadrspamd-0b2882ea9b6722a6ca9533e9121a5f30bd55fc49.tar.gz
rspamd-0b2882ea9b6722a6ca9533e9121a5f30bd55fc49.zip
[Fix] Fix accepting the first update when local idx is -1
Diffstat (limited to 'src/fuzzy_storage.c')
-rw-r--r--src/fuzzy_storage.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c
index cc613e68d..cfb29c0b7 100644
--- a/src/fuzzy_storage.c
+++ b/src/fuzzy_storage.c
@@ -911,7 +911,8 @@ rspamd_fuzzy_mirror_process_update (struct fuzzy_master_update_session *session,
const guchar *p;
gchar *src = NULL, *psrc;
gsize remain;
- guint32 revision, our_rev, len, cnt = 0;
+ gint32 revision, our_rev;
+ guint32 len, cnt = 0;
struct fuzzy_peer_cmd cmd, *pcmd;
enum {
read_len = 0,
@@ -950,13 +951,13 @@ rspamd_fuzzy_mirror_process_update (struct fuzzy_master_update_session *session,
*/
p = rspamd_http_message_get_body (msg, &remain);
- if (remain > sizeof (guint32) * 2) {
- memcpy (&revision, p, sizeof (guint32));
- revision = GUINT32_TO_LE (revision);
+ if (remain > sizeof (gint32) * 2) {
+ memcpy (&revision, p, sizeof (gint32));
+ revision = GINT32_TO_LE (revision);
our_rev = rspamd_fuzzy_backend_version (session->ctx->backend, src);
if (revision <= our_rev) {
- msg_err ("remote revision:d %d is older than ours: %d, refusing update",
+ msg_err ("remote revision: %d is older than ours: %d, refusing update",
revision, our_rev);
g_free (psrc);
@@ -968,8 +969,8 @@ rspamd_fuzzy_mirror_process_update (struct fuzzy_master_update_session *session,
revision, our_rev);
}
- remain -= sizeof (guint32);
- p += sizeof (guint32);
+ remain -= sizeof (gint32);
+ p += sizeof (gint32);
}
else {
msg_err ("short update message, not processing");