From 70bdb895a55fc52a4c94519dbc591a520ec86949 Mon Sep 17 00:00:00 2001 From: Heiko Reese Date: Sat, 21 Aug 2021 19:19:53 +0200 Subject: [PATCH] =?UTF-8?q?=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libexim-encrypt-dlfunc.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/libexim-encrypt-dlfunc.c b/src/libexim-encrypt-dlfunc.c index 6d74f35..ed2d865 100644 --- a/src/libexim-encrypt-dlfunc.c +++ b/src/libexim-encrypt-dlfunc.c @@ -6,6 +6,9 @@ #include #include +/* Exim4 dlfunc API header */ +#include + /* * This is a set of workarounds for the different exim local_scan ABI versions, distribution patches and missing * definitions which prevent late binding. @@ -30,7 +33,7 @@ #define store_get_untainted(size) store_get(size, FALSE) #define store_get_tainted(size) store_get(size, TRUE) -#define string_copy(s) string_copy_function(s) +# define string_copy(s) string_copy_function(s) extern uschar * string_copy_function(const uschar *); // local_scan ABI version > 3 @@ -38,12 +41,8 @@ extern uschar * string_copy_function(const uschar *); #define DLFUNC_IMPL #define store_get_untainted(size) store_get(size, FALSE) #define store_get_tainted(size) store_get(size, TRUE) - #endif -/* Exim4 dlfunc API header */ -#include - /* * Encrypt message using crypto_secretbox_easy(). * @@ -90,8 +89,7 @@ int sodium_crypto_secretbox_encrypt_password(uschar **yield, int argc, uschar *a unsigned char nonce[crypto_secretbox_NONCEBYTES]; randombytes_buf(nonce, sizeof nonce); if (crypto_secretbox_easy(ciphertext, message, messagelen, nonce, keybytes) != 0) { - *yield = string_copy(US - "Encryption error after crypto_secretbox_easy()"); + *yield = string_copy((unsigned char *) "Encryption error after crypto_secretbox_easy()"); return ERROR; } @@ -111,8 +109,7 @@ int sodium_crypto_secretbox_encrypt_password(uschar **yield, int argc, uschar *a sodium_base64_VARIANT_ORIGINAL); // return base64-encoded ciphertext - *yield = string_copy(US - outstring); + *yield = string_copy(outstring); return OK; } @@ -130,7 +127,9 @@ int sodium_crypto_secretbox_decrypt_password(uschar **yield, int argc, uschar *a } // check argument count if (argc != 2) { - *yield = string_sprintf("Wrong number of arguments (got %i, expected 2)", argc); + *yield = + string_sprintf + ("Wrong number of arguments (got %i, expected 2)", argc); return ERROR; } // get password @@ -157,8 +156,7 @@ int sodium_crypto_secretbox_decrypt_password(uschar **yield, int argc, uschar *a NULL, &combined_message_len, NULL, sodium_base64_VARIANT_ORIGINAL); if (b64err != 0) { - *yield = string_copy(US - "Error decoding base64 encoded ciphertext"); + *yield = string_copy((unsigned char *) "Error decoding base64 encoded ciphertext"); return ERROR; } @@ -174,14 +172,12 @@ int sodium_crypto_secretbox_decrypt_password(uschar **yield, int argc, uschar *a // decrypt message if (crypto_secretbox_open_easy(cleartext, &combined_message[crypto_secretbox_NONCEBYTES], combined_message_len - crypto_secretbox_NONCEBYTES, nonce, keybytes) != 0) { - *yield = string_copy(US - "Decryption error after crypto_secretbox_open_easy()"); + *yield = string_copy((unsigned char *) "Decryption error after crypto_secretbox_open_easy()"); return ERROR; } // return cleartext - *yield = string_copy(US - cleartext); + *yield = string_copy(cleartext); return OK; }