]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
ENCODER & DECODER: set params on all encoder/decoder instances, unconditionally
authorRichard Levitte <levitte@openssl.org>
Fri, 16 Oct 2020 05:58:33 +0000 (07:58 +0200)
committerRichard Levitte <levitte@openssl.org>
Sat, 17 Oct 2020 09:56:37 +0000 (11:56 +0200)
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)

crypto/encode_decode/decoder_meth.c
crypto/encode_decode/encoder_meth.c

index f27bb4c1e4bab838373f7e3f18b12a4c04ac2864..edbb140c44210adecb90ba7e2e14e639178d1dc8 100644 (file)
@@ -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)
index bee54bf63ac3b71db25cebcfa8e25fa009ba436f..adff759bd429a939f38ff7896de1490d14c107ff 100644 (file)
@@ -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)