From b6a350ef3ac3b2e3590f3b4ef04c9b97f14cc738 Mon Sep 17 00:00:00 2001 From: Heiko Reese Date: Sat, 11 Sep 2021 12:49:41 +0200 Subject: [PATCH] debugging meson build tests --- src/common.c | 6 +----- src/libexim-encrypt-dlfunc-decrypt-secretbox.c | 9 ++++++--- ...t_libexim-encrypt-dlfunc-decrypt-secretbox.sh | 16 ++++++++-------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/common.c b/src/common.c index 13e93a3..12d5c90 100644 --- a/src/common.c +++ b/src/common.c @@ -53,15 +53,11 @@ char *read_first_line(const char *filename) { return cipherstring; } -typedef struct { - unsigned char *string; - size_t length; -} Password; - void base64_decode_string(const char *input, unsigned char **outstring, size_t *outlen) { size_t input_len = strlen(input); size_t outmaxlen = input_len / 4 * 3; *outstring = malloc(outmaxlen * sizeof(unsigned char)); + fprintf(stderr, " Input: |%s| [%zu]\n", input, input_len); int b64err = sodium_base642bin(*outstring, outmaxlen, (const char *) input, input_len, NULL, outlen, NULL, sodium_base64_VARIANT_ORIGINAL); if (b64err != 0) { diff --git a/src/libexim-encrypt-dlfunc-decrypt-secretbox.c b/src/libexim-encrypt-dlfunc-decrypt-secretbox.c index 5a0dcfd..66271c9 100644 --- a/src/libexim-encrypt-dlfunc-decrypt-secretbox.c +++ b/src/libexim-encrypt-dlfunc-decrypt-secretbox.c @@ -64,9 +64,12 @@ int main(int argc, char *argv[]) { // check environment for LIBEXIM_PASSWORD password_env = getenv(ENVVAR_PASSWORD_NAME); if (password_env != NULL && strlen(password_env) > 0) { - password_len = strlen((const char *) password_env); - password = malloc(password_len + 1); - strncpy(password, password_env, password_len); +// password_len = strlen((const char *) password_env); +// password = malloc(password_len); +// sodium_memzero(password, password_len); +// strncpy(password, password_env, password_len); + password = password_env; + password_len = strlen(password); mode |= PASSENV; } diff --git a/src/test_libexim-encrypt-dlfunc-decrypt-secretbox.sh b/src/test_libexim-encrypt-dlfunc-decrypt-secretbox.sh index 97a9d03..c255510 100755 --- a/src/test_libexim-encrypt-dlfunc-decrypt-secretbox.sh +++ b/src/test_libexim-encrypt-dlfunc-decrypt-secretbox.sh @@ -15,22 +15,24 @@ CIPHERTEXT_FILE02="$(mktemp)" echo -n "${TEST_CIPHERTEXT01}" > "${CIPHERTEXT_FILE01}" echo -n "${TEST_CIPHERTEXT02}" > "${CIPHERTEXT_FILE02}" -DECRYPTED01="$(LIBEXIM_PASSWORD="${TEST_PASSWORD}" src/libexim-encrypt-dlfunc-decrypt-secretbox ${TEST_CIPHERTEXT01})" +export LIBEXIM_PASSWORD="${TEST_PASSWORD}" +#DECRYPTED01="$(LIBEXIM_PASSWORD="${TEST_PASSWORD}" src/libexim-encrypt-dlfunc-decrypt-secretbox ${TEST_CIPHERTEXT01})" +DECRYPTED01="$(src/libexim-encrypt-dlfunc-decrypt-secretbox ${TEST_CIPHERTEXT01})" if [ "${DECRYPTED01}" == "${TEST_CLEARTEXT}" ] ; then echo "ok 1 - decrypt commandline argument with password from environment successful" else echo "not ok 1 - decrypt commandline argument with password from environment unsuccessful" fi -DECRYPTED02="$(LIBEXIM_PASSWORD="${TEST_PASSWORD}" src/libexim-encrypt-dlfunc-decrypt-secretbox --infile ${CIPHERTEXT_FILE01})" +#DECRYPTED02="$(LIBEXIM_PASSWORD="${TEST_PASSWORD}" src/libexim-encrypt-dlfunc-decrypt-secretbox --infile ${CIPHERTEXT_FILE01})" +DECRYPTED02="$(src/libexim-encrypt-dlfunc-decrypt-secretbox --infile ${CIPHERTEXT_FILE01})" if [ "${DECRYPTED02}" == "${TEST_CLEARTEXT}" ] ; then echo "ok 2 - decrypt file contents with password from environment successful" else - echo "${CIPHERTEXT_FILE01}" - cat "${CIPHERTEXT_FILE01}" echo "not ok 2 - decrypt file contents with password from environment unsuccessful" fi -unset LIBEXIM_PASSWORD +#unset LIBEXIM_PASSWORD +export -n LIBEXIM_PASSWORD DECRYPTED03="$(src/libexim-encrypt-dlfunc-decrypt-secretbox -p ${TEST_PASSWORD} ${TEST_CIPHERTEXT02})" if [ "${DECRYPTED03}" == "${TEST_CLEARTEXT}" ] ; then @@ -43,7 +45,5 @@ DECRYPTED04="$(src/libexim-encrypt-dlfunc-decrypt-secretbox -p ${TEST_PASSWORD} if [ "${DECRYPTED04}" == "${TEST_CLEARTEXT}" ] ; then echo "ok 4 - decrypt file contents with password from commandline successful" else - echo "${CIPHERTEXT_FILE02}" - cat "${CIPHERTEXT_FILE02}" echo "not ok 4 - decrypt file contents with password from commandline unsuccessful" -fi \ No newline at end of file +fi