From b4bf269f08802af01b400702a920eb67fbf4f0a4 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Thu, 18 Jul 2019 13:48:55 -0700 Subject: Set key_set ivar to false if encrypt/decrypt called without key This makes it obvious you have made a mistake if you call key= and then encrypt or decrypt. Calling encrypt or decrypt without an argument automatically sets the key to NULL, in which case the key_set ivar should be changed from false to true given if had been set before calling encrypt or decrypt. Fixes Ruby Bug 8720. --- ext/openssl/ossl_cipher.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'ext/openssl/ossl_cipher.c') diff --git a/ext/openssl/ossl_cipher.c b/ext/openssl/ossl_cipher.c index 93cb0ed2..66bf0beb 100644 --- a/ext/openssl/ossl_cipher.c +++ b/ext/openssl/ossl_cipher.c @@ -237,8 +237,7 @@ ossl_cipher_init(int argc, VALUE *argv, VALUE self, int mode) ossl_raise(eCipherError, NULL); } - if (p_key) - rb_ivar_set(self, id_key_set, Qtrue); + rb_ivar_set(self, id_key_set, p_key ? Qtrue : Qfalse); return self; } -- cgit v1.2.3