diff options
author | Richard Levitte <levitte@openssl.org> | 2020-10-16 08:58:33 +0300 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2020-10-17 12:56:37 +0300 |
commit | 9096809b209a03eb3948242e702b19526e675d57 (patch) | |
tree | 41b610b4676cb6fa04816d7072f3258fc3a5d2e1 | |
parent | a1fc4642e1cedbce54945da36d256bbb12ff752d (diff) |
ENCODER & DECODER: set params on all encoder/decoder instances, unconditionally
OSSL_DECODER_CTX_set_params() and OSSL_ENCODER_CTX_set_params() would
stop as soon as a decoder / encoder instance failed, which leaves the
rest of them with a possibly previous and different value.
Instead, these functions will now call them all, but will return 0 if
any of the instance calls failed.
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/13156)
-rw-r--r-- | crypto/encode_decode/decoder_meth.c | 5 | ||||
-rw-r--r-- | crypto/encode_decode/encoder_meth.c | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/crypto/encode_decode/decoder_meth.c b/crypto/encode_decode/decoder_meth.c index f27bb4c1e4..edbb140c44 100644 --- a/crypto/encode_decode/decoder_meth.c +++ b/crypto/encode_decode/decoder_meth.c @@ -493,6 +493,7 @@ OSSL_DECODER_CTX *OSSL_DECODER_CTX_new(void) int OSSL_DECODER_CTX_set_params(OSSL_DECODER_CTX *ctx, const OSSL_PARAM params[]) { + int ok = 1; size_t i; size_t l; @@ -516,9 +517,9 @@ int OSSL_DECODER_CTX_set_params(OSSL_DECODER_CTX *ctx, if (decoderctx == NULL || decoder->set_ctx_params == NULL) continue; if (!decoder->set_ctx_params(decoderctx, params)) - return 0; + ok = 0; } - return 1; + return ok; } void OSSL_DECODER_CTX_free(OSSL_DECODER_CTX *ctx) diff --git a/crypto/encode_decode/encoder_meth.c b/crypto/encode_decode/encoder_meth.c index bee54bf63a..adff759bd4 100644 --- a/crypto/encode_decode/encoder_meth.c +++ b/crypto/encode_decode/encoder_meth.c @@ -503,6 +503,7 @@ OSSL_ENCODER_CTX *OSSL_ENCODER_CTX_new(void) int OSSL_ENCODER_CTX_set_params(OSSL_ENCODER_CTX *ctx, const OSSL_PARAM params[]) { + int ok = 1; size_t i; size_t l; @@ -524,9 +525,9 @@ int OSSL_ENCODER_CTX_set_params(OSSL_ENCODER_CTX *ctx, if (encoderctx == NULL || encoder->set_ctx_params == NULL) continue; if (!encoder->set_ctx_params(encoderctx, params)) - return 0; + ok = 0; } - return 1; + return ok; } void OSSL_ENCODER_CTX_free(OSSL_ENCODER_CTX *ctx) |