]> source.dussan.org Git - rspamd.git/commitdiff
Fix parsing of openssl keys by semicolon splitting
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 22 Oct 2015 08:45:14 +0000 (09:45 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 22 Oct 2015 08:45:14 +0000 (09:45 +0100)
src/libutil/http.c

index 1afa9ac18061b26c39d9ba42e1b1aad12239fde8..beb27cf9bca1b9a99dd866fafdcbde9019ae4991 100644 (file)
@@ -2259,11 +2259,24 @@ gpointer
 rspamd_http_connection_make_key (gchar *key, gsize keylen)
 {
        guchar *decoded_sk, *decoded_pk;
+       gchar *semicolon;
        gsize decoded_len;
        struct rspamd_http_keypair *kp;
 
-       decoded_sk = rspamd_decode_base32 (key, keylen / 2, &decoded_len);
-       decoded_pk = rspamd_decode_base32 (key + keylen / 2, keylen / 2, &decoded_len);
+       semicolon = memchr (key, ':', keylen);
+
+       if (semicolon) {
+               decoded_sk = rspamd_decode_base32 (key, semicolon - key, &decoded_len);
+               decoded_pk = rspamd_decode_base32 (semicolon + 1,
+                               keylen - (semicolon - key + 1),
+                               &decoded_len);
+       }
+       else {
+               decoded_sk = rspamd_decode_base32 (key, keylen / 2, &decoded_len);
+               decoded_pk = rspamd_decode_base32 (key + keylen / 2,
+                               keylen / 2,
+                               &decoded_len);
+       }
 
        if (decoded_pk != NULL && decoded_sk != NULL) {
                if (decoded_len == rspamd_cryptobox_pk_bytes ()) {
@@ -2274,7 +2287,7 @@ rspamd_http_connection_make_key (gchar *key, gsize keylen)
                        blake2b (kp->id, kp->pk, NULL, sizeof (kp->id),
                                        rspamd_cryptobox_pk_bytes (), 0);
 
-                       return (gpointer)kp;
+                       return (gpointer) kp;
                }
                g_free (decoded_pk);
                g_free (decoded_sk);