From: Igor Ustinov Date: Thu, 13 Nov 2025 12:47:48 +0000 (+0100) Subject: Removed ossl_assert() calls from public OSSL_EN/DECODER_CTX_*() functions X-Git-Tag: 4.0-PRE-CLANG-FORMAT-WEBKIT~171 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=747cfae9f1328849b971a04f9f3312a4baae34b1;p=thirdparty%2Fopenssl.git Removed ossl_assert() calls from public OSSL_EN/DECODER_CTX_*() functions Reviewed-by: Richard Levitte Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/29120) --- diff --git a/crypto/encode_decode/decoder_lib.c b/crypto/encode_decode/decoder_lib.c index 54fc3519901..af5847e517a 100644 --- a/crypto/encode_decode/decoder_lib.c +++ b/crypto/encode_decode/decoder_lib.c @@ -165,7 +165,7 @@ int OSSL_DECODER_from_data(OSSL_DECODER_CTX *ctx, const unsigned char **pdata, int OSSL_DECODER_CTX_set_selection(OSSL_DECODER_CTX *ctx, int selection) { - if (!ossl_assert(ctx != NULL)) { + if (ctx == NULL) { ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_PASSED_NULL_PARAMETER); return 0; } @@ -186,7 +186,7 @@ int OSSL_DECODER_CTX_set_selection(OSSL_DECODER_CTX *ctx, int selection) int OSSL_DECODER_CTX_set_input_type(OSSL_DECODER_CTX *ctx, const char *input_type) { - if (!ossl_assert(ctx != NULL)) { + if (ctx == NULL) { ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_PASSED_NULL_PARAMETER); return 0; } @@ -207,7 +207,7 @@ int OSSL_DECODER_CTX_set_input_type(OSSL_DECODER_CTX *ctx, int OSSL_DECODER_CTX_set_input_structure(OSSL_DECODER_CTX *ctx, const char *input_structure) { - if (!ossl_assert(ctx != NULL)) { + if (ctx == NULL) { ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_PASSED_NULL_PARAMETER); return 0; } @@ -398,7 +398,7 @@ int OSSL_DECODER_CTX_add_decoder(OSSL_DECODER_CTX *ctx, OSSL_DECODER *decoder) void *decoderctx = NULL; void *provctx = NULL; - if (!ossl_assert(ctx != NULL) || !ossl_assert(decoder != NULL)) { + if (ctx == NULL || decoder == NULL) { ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_PASSED_NULL_PARAMETER); return 0; } @@ -597,7 +597,7 @@ int OSSL_DECODER_CTX_add_extra(OSSL_DECODER_CTX *ctx, int numdecoders; STACK_OF(OSSL_DECODER) *skdecoders; - if (!ossl_assert(ctx != NULL)) { + if (ctx == NULL) { ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_PASSED_NULL_PARAMETER); return 0; } @@ -705,7 +705,7 @@ int OSSL_DECODER_CTX_get_num_decoders(OSSL_DECODER_CTX *ctx) int OSSL_DECODER_CTX_set_construct(OSSL_DECODER_CTX *ctx, OSSL_DECODER_CONSTRUCT *construct) { - if (!ossl_assert(ctx != NULL)) { + if (ctx == NULL) { ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_PASSED_NULL_PARAMETER); return 0; } @@ -722,7 +722,7 @@ int OSSL_DECODER_CTX_set_construct(OSSL_DECODER_CTX *ctx, int OSSL_DECODER_CTX_set_construct_data(OSSL_DECODER_CTX *ctx, void *construct_data) { - if (!ossl_assert(ctx != NULL)) { + if (ctx == NULL) { ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_PASSED_NULL_PARAMETER); return 0; } @@ -739,7 +739,7 @@ int OSSL_DECODER_CTX_set_construct_data(OSSL_DECODER_CTX *ctx, int OSSL_DECODER_CTX_set_cleanup(OSSL_DECODER_CTX *ctx, OSSL_DECODER_CLEANUP *cleanup) { - if (!ossl_assert(ctx != NULL)) { + if (ctx == NULL) { ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_PASSED_NULL_PARAMETER); return 0; } @@ -802,10 +802,8 @@ int OSSL_DECODER_export(OSSL_DECODER_INSTANCE *decoder_inst, OSSL_DECODER *decoder = NULL; void *decoderctx = NULL; - if (!(ossl_assert(decoder_inst != NULL) - && ossl_assert(reference != NULL) - && ossl_assert(export_cb != NULL) - && ossl_assert(export_cbarg != NULL))) { + if (decoder_inst == NULL || reference == NULL + || export_cb == NULL || export_cbarg == NULL) { ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_PASSED_NULL_PARAMETER); return 0; } diff --git a/crypto/encode_decode/encoder_lib.c b/crypto/encode_decode/encoder_lib.c index d22b1184d2a..28eecc3e0d6 100644 --- a/crypto/encode_decode/encoder_lib.c +++ b/crypto/encode_decode/encoder_lib.c @@ -169,7 +169,7 @@ int OSSL_ENCODER_to_data(OSSL_ENCODER_CTX *ctx, unsigned char **pdata, int OSSL_ENCODER_CTX_set_selection(OSSL_ENCODER_CTX *ctx, int selection) { - if (!ossl_assert(ctx != NULL)) { + if (ctx == NULL) { ERR_raise(ERR_LIB_OSSL_ENCODER, ERR_R_PASSED_NULL_PARAMETER); return 0; } @@ -179,7 +179,7 @@ int OSSL_ENCODER_CTX_set_selection(OSSL_ENCODER_CTX *ctx, int selection) return 0; } - if (!ossl_assert(selection != 0)) { + if (selection == 0) { ERR_raise(ERR_LIB_OSSL_ENCODER, ERR_R_PASSED_INVALID_ARGUMENT); return 0; } @@ -191,7 +191,7 @@ int OSSL_ENCODER_CTX_set_selection(OSSL_ENCODER_CTX *ctx, int selection) int OSSL_ENCODER_CTX_set_output_type(OSSL_ENCODER_CTX *ctx, const char *output_type) { - if (!ossl_assert(ctx != NULL) || !ossl_assert(output_type != NULL)) { + if (ctx == NULL || output_type == NULL) { ERR_raise(ERR_LIB_OSSL_ENCODER, ERR_R_PASSED_NULL_PARAMETER); return 0; } @@ -208,7 +208,7 @@ int OSSL_ENCODER_CTX_set_output_type(OSSL_ENCODER_CTX *ctx, int OSSL_ENCODER_CTX_set_output_structure(OSSL_ENCODER_CTX *ctx, const char *output_structure) { - if (!ossl_assert(ctx != NULL) || !ossl_assert(output_structure != NULL)) { + if (ctx == NULL || output_structure == NULL) { ERR_raise(ERR_LIB_OSSL_ENCODER, ERR_R_PASSED_NULL_PARAMETER); return 0; } @@ -231,7 +231,7 @@ static OSSL_ENCODER_INSTANCE *ossl_encoder_instance_new(OSSL_ENCODER *encoder, const OSSL_PROPERTY_LIST *props; const OSSL_PROPERTY_DEFINITION *prop; - if (!ossl_assert(encoder != NULL)) { + if (encoder == NULL) { ERR_raise(ERR_LIB_OSSL_ENCODER, ERR_R_PASSED_NULL_PARAMETER); return 0; } @@ -325,7 +325,7 @@ int OSSL_ENCODER_CTX_add_encoder(OSSL_ENCODER_CTX *ctx, OSSL_ENCODER *encoder) void *encoderctx = NULL; void *provctx = NULL; - if (!ossl_assert(ctx != NULL) || !ossl_assert(encoder != NULL)) { + if (ctx == NULL || encoder == NULL) { ERR_raise(ERR_LIB_OSSL_ENCODER, ERR_R_PASSED_NULL_PARAMETER); return 0; } @@ -382,7 +382,7 @@ int OSSL_ENCODER_CTX_get_num_encoders(OSSL_ENCODER_CTX *ctx) int OSSL_ENCODER_CTX_set_construct(OSSL_ENCODER_CTX *ctx, OSSL_ENCODER_CONSTRUCT *construct) { - if (!ossl_assert(ctx != NULL)) { + if (ctx == NULL) { ERR_raise(ERR_LIB_OSSL_ENCODER, ERR_R_PASSED_NULL_PARAMETER); return 0; } @@ -399,7 +399,7 @@ int OSSL_ENCODER_CTX_set_construct(OSSL_ENCODER_CTX *ctx, int OSSL_ENCODER_CTX_set_construct_data(OSSL_ENCODER_CTX *ctx, void *construct_data) { - if (!ossl_assert(ctx != NULL)) { + if (ctx == NULL) { ERR_raise(ERR_LIB_OSSL_ENCODER, ERR_R_PASSED_NULL_PARAMETER); return 0; } @@ -416,7 +416,7 @@ int OSSL_ENCODER_CTX_set_construct_data(OSSL_ENCODER_CTX *ctx, int OSSL_ENCODER_CTX_set_cleanup(OSSL_ENCODER_CTX *ctx, OSSL_ENCODER_CLEANUP *cleanup) { - if (!ossl_assert(ctx != NULL)) { + if (ctx == NULL) { ERR_raise(ERR_LIB_OSSL_ENCODER, ERR_R_PASSED_NULL_PARAMETER); return 0; }