1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
From 5b260f28d2a52f8a71d2651be4570e69dc83370a Mon Sep 17 00:00:00 2001
From: NIIBE Yutaka <gniibe@fsij.org>
Date: Wed, 29 Oct 2025 15:37:14 +0900
Subject: [PATCH 4/6] random:jent: Fix build with address sanitizer.
* random/jitterentropy-base.c (jent_entropy_collector_alloc_internal):
Annotate with gpgrt_annotate_leaked_object.
--
Cherry-pick the master commit of:
def1d4ea8f66abf23ef0def6d8d34060e1ee923e
Fixes-commit: 0ceca9993f5a94389624f6cf12e07165cd2391e4
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
---
mpi/mpiutil.c | 2 --
random/jitterentropy-base.c | 3 +++
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/mpi/mpiutil.c b/mpi/mpiutil.c
index 9625693c..b254e12f 100644
--- a/mpi/mpiutil.c
+++ b/mpi/mpiutil.c
@@ -216,17 +216,15 @@ _gcry_mpi_clear( gcry_mpi_t a )
void
_gcry_mpi_free( gcry_mpi_t a )
{
if (!a )
return;
if ((a->flags & 32))
{
-#if GPGRT_VERSION_NUMBER >= 0x011600 /* 1.22 */
gpgrt_annotate_leaked_object(a);
-#endif
return; /* Never release a constant. */
}
if ((a->flags & 4))
xfree( a->d );
else
{
_gcry_mpi_free_limb_space(a->d, a->alloced);
diff --git a/random/jitterentropy-base.c b/random/jitterentropy-base.c
index cf7630d9..0da2d78e 100644
--- a/random/jitterentropy-base.c
+++ b/random/jitterentropy-base.c
@@ -404,14 +404,17 @@ static struct rand_data
if (NULL == entropy_collector)
return NULL;
if (!(flags & JENT_DISABLE_MEMORY_ACCESS)) {
uint32_t memsize = jent_memsize(flags);
entropy_collector->mem = _gcry_calloc (1, memsize);
+#ifdef _GCRYPT_IN_LIBGCRYPT
+ gpgrt_annotate_leaked_object (entropy_collector->mem);
+#endif
#ifdef JENT_RANDOM_MEMACCESS
/*
* Transform the size into a mask - it is assumed that size is
* a power of 2.
*/
entropy_collector->memmask = memsize - 1;
--
2.51.0
|