From: Pauli Date: Thu, 24 Mar 2022 03:31:19 +0000 (+1100) Subject: Fix Coverity 1503218: negative loop bound X-Git-Tag: openssl-3.2.0-alpha1~2812 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0bcae9893b99666158dd8b35fb674e6188b0b5c3;p=thirdparty%2Fopenssl.git Fix Coverity 1503218: negative loop bound OPENSSL_sk_num returns an integer which can theoretically be negative. Assigning this to a size_t and using it as a loop bound isn't ideal. Rather than adding checked for NULL or negative returns, changing the loop index and end to int is simpler. Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/17954) --- diff --git a/crypto/encode_decode/decoder_pkey.c b/crypto/encode_decode/decoder_pkey.c index 873b514d3c6..8cb320a5cee 100644 --- a/crypto/encode_decode/decoder_pkey.c +++ b/crypto/encode_decode/decoder_pkey.c @@ -260,7 +260,7 @@ static void collect_decoder(OSSL_DECODER *decoder, void *arg) { struct collect_data_st *data = arg; STACK_OF(EVP_KEYMGMT) *keymgmts = data->keymgmts; - size_t i, end_i; + int i, end_i; EVP_KEYMGMT *keymgmt; const OSSL_PROVIDER *prov; void *provctx;