aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2015-07-09 16:41:53 +0200
committerSverker Eriksson <[email protected]>2015-11-17 12:20:52 +0100
commit5e40dfbf957df2b64dc7e713c5c8fc83ea538f52 (patch)
treebe789e941f25e85ec25addd622f5352e3876d1e5 /lib/crypto
parentcfc8f82f1f39da114574a28c57f5d4a29ebbafaf (diff)
downloadotp-5e40dfbf957df2b64dc7e713c5c8fc83ea538f52.tar.gz
otp-5e40dfbf957df2b64dc7e713c5c8fc83ea538f52.tar.bz2
otp-5e40dfbf957df2b64dc7e713c5c8fc83ea538f52.zip
Fix bug for aes_cfb_128_encrypt with empty binary
causing OpenSSL 0.9.8h to crash with evp_enc.c(282): OpenSSL internal error, assertion failed: inl > 0
Diffstat (limited to 'lib/crypto')
-rw-r--r--lib/crypto/c_src/crypto.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/crypto/c_src/crypto.c b/lib/crypto/c_src/crypto.c
index 595ee65415..3add54bcd3 100644
--- a/lib/crypto/c_src/crypto.c
+++ b/lib/crypto/c_src/crypto.c
@@ -1332,10 +1332,15 @@ static ERL_NIF_TERM block_crypt_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM
EVP_CIPHER_CTX_ctrl(&ctx, EVP_CTRL_SET_RC2_KEY_BITS, key.size * 8, NULL)) ||
!EVP_CipherInit_ex(&ctx, NULL, NULL,
key.data, ivec_size ? ivec.data : NULL, -1) ||
- !EVP_CIPHER_CTX_set_padding(&ctx, 0) ||
- !EVP_CipherUpdate(&ctx, out, &out_size, text.data, text.size) ||
- (ASSERT(out_size == text.size), 0) ||
- !EVP_CipherFinal_ex(&ctx, out + out_size, &out_size)) {
+ !EVP_CIPHER_CTX_set_padding(&ctx, 0)) {
+
+ return enif_raise_exception(env, atom_notsup);
+ }
+
+ if (text.size > 0 && /* OpenSSL 0.9.8h asserts text.size > 0 */
+ (!EVP_CipherUpdate(&ctx, out, &out_size, text.data, text.size)
+ || (ASSERT(out_size == text.size), 0)
+ || !EVP_CipherFinal_ex(&ctx, out + out_size, &out_size))) {
EVP_CIPHER_CTX_cleanup(&ctx);
return enif_raise_exception(env, atom_notsup);