1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-11-21 14:00:51 +03:00

openssl: fix memleak in _libssh2_dsa_sha1_verify()

This commit is contained in:
Kamil Dudka
2015-06-12 12:03:28 +02:00
parent e9536edede
commit 418be878ad

View File

@@ -154,17 +154,17 @@ _libssh2_dsa_sha1_verify(libssh2_dsa_ctx * dsactx,
{ {
unsigned char hash[SHA_DIGEST_LENGTH]; unsigned char hash[SHA_DIGEST_LENGTH];
DSA_SIG dsasig; DSA_SIG dsasig;
int ret; int ret = -1;
dsasig.r = BN_new(); dsasig.r = BN_new();
BN_bin2bn(sig, 20, dsasig.r); BN_bin2bn(sig, 20, dsasig.r);
dsasig.s = BN_new(); dsasig.s = BN_new();
BN_bin2bn(sig + 20, 20, dsasig.s); BN_bin2bn(sig + 20, 20, dsasig.s);
if (_libssh2_sha1(m, m_len, hash)) if (!_libssh2_sha1(m, m_len, hash))
return -1; /* _libssh2_sha1() succeeded */
ret = DSA_do_verify(hash, SHA_DIGEST_LENGTH, &dsasig, dsactx); ret = DSA_do_verify(hash, SHA_DIGEST_LENGTH, &dsasig, dsactx);
BN_clear_free(dsasig.s); BN_clear_free(dsasig.s);
BN_clear_free(dsasig.r); BN_clear_free(dsasig.r);