mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-03-17 21:11:13 +01:00
BUG/MINOR: ssl-sample: Fix sample_conv_sha2() by checking EVP_Digest* failures
In sample_conv_sha2(), calls to EVP_Digest* can fail. So we must check return value of each call and report a error on failure and release the digest context. This patch should fix the issue #3274. It should be backported as far as 2.6.
This commit is contained in:
parent
b48c9a1465
commit
bfe5a2c3d7
@ -147,9 +147,14 @@ static int sample_conv_sha2(const struct arg *arg_p, struct sample *smp, void *p
|
||||
mdctx = EVP_MD_CTX_new();
|
||||
if (!mdctx)
|
||||
return 0;
|
||||
EVP_DigestInit_ex(mdctx, evp, NULL);
|
||||
EVP_DigestUpdate(mdctx, smp->data.u.str.area, smp->data.u.str.data);
|
||||
EVP_DigestFinal_ex(mdctx, (unsigned char*)trash->area, &digest_length);
|
||||
|
||||
if (!EVP_DigestInit_ex(mdctx, evp, NULL) ||
|
||||
!EVP_DigestUpdate(mdctx, smp->data.u.str.area, smp->data.u.str.data) ||
|
||||
!EVP_DigestFinal_ex(mdctx, (unsigned char*)trash->area, &digest_length)) {
|
||||
EVP_MD_CTX_free(mdctx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
trash->data = digest_length;
|
||||
|
||||
EVP_MD_CTX_free(mdctx);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user