Skip to content

Commit 0ded703

Browse files
Fix memory leak in pg_hmac
The intermittent h buffer was not freed, causing it to leak. Backpatch through 14 where HMAC was refactored to the current API. Author: Sergey Shinderuk <s.shinderuk@postgrespro.ru> Discussion: https://postgr.es/m/af07e620-7e28-a742-4637-2bc44aa7c2be@postgrespro.ru Backpatch-through: 14
1 parent 8c1144b commit 0ded703

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/common/hmac.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,17 +232,22 @@ pg_hmac_final(pg_hmac_ctx *ctx, uint8 *dest, size_t len)
232232
memset(h, 0, ctx->digest_size);
233233

234234
if (pg_cryptohash_final(ctx->hash, h, ctx->digest_size) < 0)
235+
{
236+
FREE(h);
235237
return -1;
238+
}
236239

237240
/* H(K XOR opad, tmp) */
238241
if (pg_cryptohash_init(ctx->hash) < 0 ||
239242
pg_cryptohash_update(ctx->hash, ctx->k_opad, ctx->block_size) < 0 ||
240243
pg_cryptohash_update(ctx->hash, h, ctx->digest_size) < 0 ||
241244
pg_cryptohash_final(ctx->hash, dest, len) < 0)
242245
{
246+
FREE(h);
243247
return -1;
244248
}
245249

250+
FREE(h);
246251
return 0;
247252
}
248253

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy