1
1

wincng.c: fixed possible memory leak in _libssh2_wincng_hash

If _libssh2_wincng_hash_update failed _libssh2_wincng_hash_final
would never have been called before.

Reported by Zenju.
Этот коммит содержится в:
Marc Hoersken 2015-12-22 13:36:56 +01:00
родитель 9bf32da607
Коммит d0ffeba72e

Просмотреть файл

@ -415,16 +415,15 @@ _libssh2_wincng_hash(unsigned char *data, unsigned long datalen,
unsigned char *hash, unsigned long hashlen) unsigned char *hash, unsigned long hashlen)
{ {
_libssh2_wincng_hash_ctx ctx; _libssh2_wincng_hash_ctx ctx;
int ret;
if (!_libssh2_wincng_hash_init(&ctx, hAlg, hashlen, NULL, 0)) { ret = _libssh2_wincng_hash_init(&ctx, hAlg, hashlen, NULL, 0);
if (!_libssh2_wincng_hash_update(&ctx, data, datalen)) { if (!ret) {
if (!_libssh2_wincng_hash_final(&ctx, hash)) { ret = _libssh2_wincng_hash_update(&ctx, data, datalen);
return 0; ret |= _libssh2_wincng_hash_final(&ctx, hash);
}
}
} }
return -1; return ret;
} }