summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2021-07-15 14:56:21 +0900
committerNIIBE Yutaka <gniibe@fsij.org>2021-08-18 09:42:15 +0900
commit709a41ef540e6daf2b384a565c6a7f7b79c9c36d (patch)
tree17a793b10b41c6a2e442517d739f1b27f323b80d
parentb2b8fa5edb1ae77d0a72ab2bd285909839a087ac (diff)
downloadlibgcrypt-709a41ef540e6daf2b384a565c6a7f7b79c9c36d.tar.gz
hmac: Use xfree.
* src/hmac256.c [STANDALONE] (xfree): Define. (_gcry_hmac256_new, _gcry_hmac256_release): Use xfree. (_gcry_hmac256_file): Likewise. -- Backport the master commit of: db9f7abb7af7b5c5bc2ec356c614a5cdb88d75a6 Fixes-commit: 3e3b520fb32a37c5c23762531a7b3168e112ac36 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
-rw-r--r--src/hmac256.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/hmac256.c b/src/hmac256.c
index 2d66079c..08827359 100644
--- a/src/hmac256.c
+++ b/src/hmac256.c
@@ -70,6 +70,7 @@ typedef uint32_t u32;
#ifdef STANDALONE
#define xtrymalloc(a) malloc((a))
#define gpg_err_set_errno(a) (errno = (a))
+#define xfree(a) free((a))
#else
#include "g10lib.h"
#endif
@@ -341,7 +342,7 @@ _gcry_hmac256_new (const void *key, size_t keylen)
tmphd = _gcry_hmac256_new (NULL, 0);
if (!tmphd)
{
- free (hd);
+ xfree (hd);
return NULL;
}
_gcry_hmac256_update (tmphd, key, keylen);
@@ -373,7 +374,7 @@ _gcry_hmac256_release (hmac256_context_t ctx)
/* Note: We need to take care not to modify errno. */
if (ctx->use_hmac)
my_wipememory (ctx->opad, 64);
- free (ctx);
+ xfree (ctx);
}
}
@@ -489,7 +490,7 @@ _gcry_hmac256_file (void *result, size_t resultsize, const char *filename,
while ( (nread = fread (buffer, 1, buffer_size, fp)))
_gcry_hmac256_update (hd, buffer, nread);
- free (buffer);
+ xfree (buffer);
if (ferror (fp))
{