diff options
author | Jeremy Evans <code@jeremyevans.net> | 2019-07-18 13:48:55 -0700 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2019-07-18 13:52:20 -0700 |
commit | b4bf269f08802af01b400702a920eb67fbf4f0a4 (patch) | |
tree | de0ebfcf2bade2b62ef4622fcdeaf3f771fba8aa /ext/openssl/ossl_cipher.c | |
parent | 5953035e91c3e11ea71e73cc996be7f7fc9d4c33 (diff) | |
download | ruby-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.c | 3 |
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; } |