From: Dmitry Belyavskiy Date: Tue, 29 Mar 2016 19:08:43 +0000 (+0300) Subject: Try to fix a strange segfault X-Git-Tag: v1.1.0.2~26 X-Git-Url: http://wagner.pp.ru/gitweb/?a=commitdiff_plain;h=98faf872c8119d1f7c980d27a56e65a4a919e16c;p=openssl-gost%2Fengine.git Try to fix a strange segfault --- diff --git a/gost_crypt.c b/gost_crypt.c index 8587bd1..b9385a1 100644 --- a/gost_crypt.c +++ b/gost_crypt.c @@ -584,7 +584,7 @@ int gost_cipher_ctl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr) c->key_meshing = cur_meshing; return ret; } else { - return 0; + return 0; } #endif #ifdef EVP_CTRL_KEY_MESH @@ -602,7 +602,7 @@ int gost_cipher_ctl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr) c->key_meshing = arg; return 1; - } + } #endif default: GOSTerr(GOST_F_GOST_CIPHER_CTL, @@ -696,9 +696,15 @@ int gost89_get_asn1_parameters(EVP_CIPHER_CTX *ctx, ASN1_TYPE *params) } { - ASN1_TYPE tmp; - ASN1_TYPE_set(&tmp, V_ASN1_OCTET_STRING, gcp->iv); - EVP_CIPHER_get_asn1_iv(ctx, &tmp); + ASN1_TYPE *tmp = ASN1_TYPE_new(); + if (tmp == NULL) { + GOST_CIPHER_PARAMS_free(gcp); + GOSTerr(GOST_F_GOST89_GET_ASN1_PARAMETERS, ERR_R_MALLOC_FAILURE); + return -1; + } + ASN1_TYPE_set(tmp, V_ASN1_OCTET_STRING, gcp->iv); + EVP_CIPHER_get_asn1_iv(ctx, tmp); + ASN1_TYPE_free(tmp); } GOST_CIPHER_PARAMS_free(gcp);