aboutsummaryrefslogtreecommitdiffstats
path: root/ext/openssl/ossl_cipher.c
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-07-18 13:48:55 -0700
committerJeremy Evans <code@jeremyevans.net>2019-07-18 13:52:20 -0700
commitb4bf269f08802af01b400702a920eb67fbf4f0a4 (patch)
treede0ebfcf2bade2b62ef4622fcdeaf3f771fba8aa /ext/openssl/ossl_cipher.c
parent5953035e91c3e11ea71e73cc996be7f7fc9d4c33 (diff)
downloadruby-openssl-b4bf269f08802af01b400702a920eb67fbf4f0a4.tar.gz
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.
Diffstat (limited to 'ext/openssl/ossl_cipher.c')
-rw-r--r--ext/openssl/ossl_cipher.c3
1 files changed, 1 insertions, 2 deletions
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;
}