From: Dmitry Belyavskiy Date: Sat, 29 Dec 2018 12:01:32 +0000 (+0300) Subject: Some PVS Studio nits X-Git-Tag: v3.0.0~315 X-Git-Url: http://wagner.pp.ru/gitweb/?a=commitdiff_plain;h=6087586263eb1351a5fa370b233b8d747d0e1f59;p=openssl-gost%2Fengine.git Some PVS Studio nits --- diff --git a/benchmark/sign.c b/benchmark/sign.c index 417d8dd..2d1d786 100644 --- a/benchmark/sign.c +++ b/benchmark/sign.c @@ -131,6 +131,10 @@ int main(int argc, char **argv) fflush(stdout); siglen = EVP_PKEY_size(pkey); sigbuf = malloc(siglen * cycles); + if (!sigbuf) { + fprintf(stderr, "No tests were run, malloc failure.\n"); + exit(1); + } for (pass = 0; pass < 2; pass++) { struct timespec ts; diff --git a/gost_ec_keyx.c b/gost_ec_keyx.c index a95df33..6efa3e8 100644 --- a/gost_ec_keyx.c +++ b/gost_ec_keyx.c @@ -251,8 +251,7 @@ static int pkey_GOST_ECcp_encrypt(EVP_PKEY_CTX *pctx, unsigned char *out, EVP_PKEY *sec_key = EVP_PKEY_CTX_get0_peerkey(pctx); if (data->shared_ukm) { memcpy(ukm, data->shared_ukm, 8); - } else if (out) { - + } else { if (RAND_bytes(ukm, 8) <= 0) { GOSTerr(GOST_F_PKEY_GOST_ECCP_ENCRYPT, GOST_R_RNG_ERROR); return 0; diff --git a/gost_keyexpimp.c b/gost_keyexpimp.c index caa6171..1f058a1 100644 --- a/gost_keyexpimp.c +++ b/gost_keyexpimp.c @@ -84,7 +84,7 @@ int gost_kexp15(const unsigned char *shared_key, const int shared_len, /* * Function expects that shared_key is a preallocated buffer - * with length defined as expkeylen - mac_len defined by mac_nid + * with length defined as expkeylen + mac_len defined by mac_nid * */ int gost_kimp15(const unsigned char *expkey, const size_t expkeylen, int cipher_nid, const unsigned char *cipher_key, diff --git a/test_tlstree.c b/test_tlstree.c index 08caf90..df25742 100644 --- a/test_tlstree.c +++ b/test_tlstree.c @@ -132,7 +132,7 @@ int main(void) EVP_Cipher(enc, data0_processed+sizeof(data0), mac0, 16); hexdump(stderr, "ENC0 result", data0_processed, 31); - if (memcmp(enc0_etl, data0_processed, 16) != 0) { + if (memcmp(enc0_etl, data0_processed, sizeof(data0_processed)) != 0) { fprintf(stderr, "ENC0 mismatch"); exit(1); }