diff options
author | Jack Lloyd <[email protected]> | 2018-07-24 15:43:51 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-07-24 15:43:51 -0400 |
commit | 68a7450b87020393020f5efc98bd9d5bf5acd629 (patch) | |
tree | aa98463638006737509bb97f92d046cfed529485 /src | |
parent | d24cca944011863f6afe0b5be8fb2678128947aa (diff) |
Only print FFI exceptions to stdout if an env var is set
So debugging is possible but default is silent.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/ffi/ffi.cpp | 5 | ||||
-rw-r--r-- | src/tests/test_ffi.cpp | 3 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/lib/ffi/ffi.cpp b/src/lib/ffi/ffi.cpp index 74c576631..48b9cf803 100644 --- a/src/lib/ffi/ffi.cpp +++ b/src/lib/ffi/ffi.cpp @@ -16,7 +16,10 @@ namespace Botan_FFI { int ffi_error_exception_thrown(const char* func_name, const char* exn, int rc) { - fprintf(stderr, "in %s exception '%s' returning %d\n", func_name, exn, rc); + if(std::getenv("BOTAN_FFI_PRINT_EXCEPTIONS")) + { + std::fprintf(stderr, "in %s exception '%s' returning %d\n", func_name, exn, rc); + } return rc; } diff --git a/src/tests/test_ffi.cpp b/src/tests/test_ffi.cpp index de80f3e3b..8f3639ad4 100644 --- a/src/tests/test_ffi.cpp +++ b/src/tests/test_ffi.cpp @@ -868,6 +868,9 @@ class FFI_Unit_Tests final : public Test TEST_FFI_OK(botan_block_cipher_clear, (cipher)); + TEST_FFI_RC(BOTAN_FFI_ERROR_KEY_NOT_SET, botan_block_cipher_encrypt_blocks, (cipher, nullptr, nullptr, 0)); + TEST_FFI_RC(BOTAN_FFI_ERROR_KEY_NOT_SET, botan_block_cipher_decrypt_blocks, (cipher, nullptr, nullptr, 0)); + TEST_FFI_RC(16, botan_block_cipher_block_size, (cipher)); size_t min_keylen = 0, max_keylen = 0, mod_keylen = 0; |