aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/keypairs_cache.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-10-19 11:40:16 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-10-19 11:40:16 +0100
commiteb677991227e19ed2cd573dab1b94cd27ac49e85 (patch)
tree1155812c933d45b154c1c96bc806b95d937fe5fc /src/libutil/keypairs_cache.c
parente0ac725505ac010cb01330501f8e869949868594 (diff)
downloadrspamd-eb677991227e19ed2cd573dab1b94cd27ac49e85.tar.gz
rspamd-eb677991227e19ed2cd573dab1b94cd27ac49e85.zip
Fix HTTP code.
Diffstat (limited to 'src/libutil/keypairs_cache.c')
-rw-r--r--src/libutil/keypairs_cache.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/libutil/keypairs_cache.c b/src/libutil/keypairs_cache.c
index eb9b5215c..8b8014e5d 100644
--- a/src/libutil/keypairs_cache.c
+++ b/src/libutil/keypairs_cache.c
@@ -31,8 +31,8 @@
#include "xxhash.h"
struct rspamd_keypair_elt {
- guchar nm[rspamd_cryptobox_NMBYTES];
- guchar pair[rspamd_cryptobox_PKBYTES + rspamd_cryptobox_SKBYTES];
+ guchar nm[rspamd_cryptobox_MAX_NMBYTES];
+ guchar pair[rspamd_cryptobox_MAX_PKBYTES + rspamd_cryptobox_MAX_SKBYTES];
};
struct rspamd_keypair_cache {
@@ -90,23 +90,24 @@ rspamd_keypair_cache_process (struct rspamd_keypair_cache *c,
g_assert (kp_local != NULL);
g_assert (kp_remote != NULL);
- memcpy (search.pair, kp_remote->pk, rspamd_cryptobox_PKBYTES);
- memcpy (&search.pair[rspamd_cryptobox_PKBYTES], kp_local->sk,
- rspamd_cryptobox_SKBYTES);
+ memset (&search, 0, sizeof (search));
+ memcpy (search.pair, kp_remote->pk, rspamd_cryptobox_pk_bytes ());
+ memcpy (&search.pair[rspamd_cryptobox_MAX_PKBYTES], kp_local->sk,
+ rspamd_cryptobox_sk_bytes ());
new = rspamd_lru_hash_lookup (c->hash, &search, time (NULL));
if (new == NULL) {
- new = g_slice_alloc (sizeof (*new));
- memcpy (new->pair, kp_remote->pk, rspamd_cryptobox_PKBYTES);
- memcpy (&new->pair[rspamd_cryptobox_PKBYTES], kp_local->sk,
- rspamd_cryptobox_SKBYTES);
+ new = g_slice_alloc0 (sizeof (*new));
+ memcpy (new->pair, kp_remote->pk, rspamd_cryptobox_pk_bytes ());
+ memcpy (&new->pair[rspamd_cryptobox_MAX_PKBYTES], kp_local->sk,
+ rspamd_cryptobox_sk_bytes ());
rspamd_cryptobox_nm (new->nm, kp_remote->pk, kp_local->sk);
rspamd_lru_hash_insert (c->hash, new, new, time (NULL), -1);
}
g_assert (new != NULL);
- memcpy (kp_remote->nm, new->nm, rspamd_cryptobox_NMBYTES);
+ memcpy (kp_remote->nm, new->nm, rspamd_cryptobox_nm_bytes ());
kp_remote->has_nm = TRUE;
#if 0
memcpy (kp_local->nm, new->nm, rspamd_cryptobox_NMBYTES);