From fba4c338569d27f72ba53d5cbaea0bd989c02748 Mon Sep 17 00:00:00 2001 From: Dmitry Belyavskiy Date: Mon, 4 May 2020 22:57:42 +0300 Subject: [PATCH] Fix coverity issue 300457 --- e_gost_err.c | 2 ++ e_gost_err.h | 1 + gost.txt | 2 ++ gost_grasshopper_cipher.c | 4 ++++ 4 files changed, 9 insertions(+) diff --git a/e_gost_err.c b/e_gost_err.c index 43f328d..caa98a2 100644 --- a/e_gost_err.c +++ b/e_gost_err.c @@ -41,6 +41,8 @@ static ERR_STRING_DATA GOST_str_functs[] = { {ERR_PACK(0, GOST_F_GOST_EC_VERIFY, 0), "gost_ec_verify"}, {ERR_PACK(0, GOST_F_GOST_GRASSHOPPER_CIPHER_CTL, 0), "gost_grasshopper_cipher_ctl"}, + {ERR_PACK(0, GOST_F_GOST_GRASSHOPPER_CIPHER_DO_CTRACPKM_OMAC, 0), + "gost_grasshopper_cipher_do_ctracpkm_omac"}, {ERR_PACK(0, GOST_F_GOST_GRASSHOPPER_SET_ASN1_PARAMETERS, 0), "gost_grasshopper_set_asn1_parameters"}, {ERR_PACK(0, GOST_F_GOST_IMIT_CTRL, 0), "gost_imit_ctrl"}, diff --git a/e_gost_err.h b/e_gost_err.h index d17a165..48588df 100644 --- a/e_gost_err.h +++ b/e_gost_err.h @@ -46,6 +46,7 @@ void ERR_GOST_error(int function, int reason, char *file, int line); # define GOST_F_GOST_EC_SIGN 109 # define GOST_F_GOST_EC_VERIFY 110 # define GOST_F_GOST_GRASSHOPPER_CIPHER_CTL 111 +# define GOST_F_GOST_GRASSHOPPER_CIPHER_DO_CTRACPKM_OMAC 160 # define GOST_F_GOST_GRASSHOPPER_SET_ASN1_PARAMETERS 112 # define GOST_F_GOST_IMIT_CTRL 113 # define GOST_F_GOST_IMIT_FINAL 114 diff --git a/gost.txt b/gost.txt index 538cccf..1ee757d 100644 --- a/gost.txt +++ b/gost.txt @@ -23,6 +23,8 @@ GOST_F_GOST_EC_KEYGEN:108:gost_ec_keygen GOST_F_GOST_EC_SIGN:109:gost_ec_sign GOST_F_GOST_EC_VERIFY:110:gost_ec_verify GOST_F_GOST_GRASSHOPPER_CIPHER_CTL:111:gost_grasshopper_cipher_ctl +GOST_F_GOST_GRASSHOPPER_CIPHER_DO_CTRACPKM_OMAC:160:\ + gost_grasshopper_cipher_do_ctracpkm_omac GOST_F_GOST_GRASSHOPPER_SET_ASN1_PARAMETERS:112:\ gost_grasshopper_set_asn1_parameters GOST_F_GOST_IMIT_CTRL:113:gost_imit_ctrl diff --git a/gost_grasshopper_cipher.c b/gost_grasshopper_cipher.c index ceafa41..f0419e3 100644 --- a/gost_grasshopper_cipher.c +++ b/gost_grasshopper_cipher.c @@ -584,6 +584,10 @@ int gost_grasshopper_cipher_do_ctracpkm_omac(EVP_CIPHER_CTX *ctx, return gost2015_final_call(ctx, c->omac_ctx, KUZNYECHIK_MAC_MAX_SIZE, c->tag, gost_grasshopper_cipher_do_ctracpkm); } + if (in == NULL) { + GOSTerr(GOST_F_GOST_GRASSHOPPER_CIPHER_DO_CTRACPKM_OMAC, ERR_R_EVP_LIB); + return -1; + } result = gost_grasshopper_cipher_do_ctracpkm(ctx, out, in, inl); /* As in and out can be the same pointer, process decrypted here */ -- 2.39.2