rng-tools/0008-Fix-a-minor-memory-leak-in-rngd_jitter.c.patch
Vladis Dronov 9a6943f11c Update to 6.13 and upstream fixes
- Update the sources to 6.13
- Add important fixes from the upstream
- Remove Provides: jitterentropy-rngd as it was retired in f29.
- Resolves: rhbz#1965318

Signed-off-by: Vladis Dronov <vdronov@redhat.com>
2021-06-16 20:48:01 +02:00

55 lines
1.8 KiB
Diff

From 05505f04b9146e3f1225c182d3fdfc2fb51a633f Mon Sep 17 00:00:00 2001
From: Vladis Dronov <vdronov@redhat.com>
Date: Sat, 12 Jun 2021 09:35:21 +0200
Subject: Fix a minor memory leak in rngd_jitter.c
While a leak is short-lived until a process memory is freed, fix it anyway.
Error: GCC_ANALYZER_WARNING (CWE-401):
rng-tools-6.12/rngd_jitter.c:396:66: warning[-Wanalyzer-malloc-leak]:
leak of 'aes_buf'
rng-tools-6.12/rngd_jitter.c:35: included_from: Included from here.
rng-tools-6.12/rngd_jitter.c:394:17: note: in expansion of macro 'message_entsrc'
Error: GCC_ANALYZER_WARNING (CWE-401): [#def4]
rng-tools-6.12/rngd_jitter.c: scope_hint: In function 'init_jitter_entropy_source'
rng-tools-6.12/rngd_jitter.c:396:66: warning[-Wanalyzer-malloc-leak]: leak of 'aes_buf'
rng-tools-6.12/rngd_jitter.c:394:17: note: in expansion of macro 'message_entsrc'
394| message_entsrc(ent_src,LOG_CONS|LOG_INFO, "Initializing AES buffer\n");
395| aes_buf = malloc(tdata[0].buf_sz);
396|-> ent_src->rng_options[JITTER_OPT_USE_AES].int_val = 0;
397| if (xread_jitter(key, AES_BLOCK, ent_src)) {
Signed-off-by: Vladis Dronov <vdronov@redhat.com>
---
rngd_jitter.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/rngd_jitter.c b/rngd_jitter.c
index 7403c02..ea29436 100644
--- a/rngd_jitter.c
+++ b/rngd_jitter.c
@@ -126,7 +126,7 @@ static struct thread_data *tdata;
static pthread_t *threads;
int pipefds[2];
-unsigned char *aes_buf;
+unsigned char *aes_buf = NULL;
static unsigned char key[AES_BLOCK];
static unsigned char iv_buf[CHUNK_SIZE] __attribute__((aligned(128)));
@@ -533,9 +533,9 @@ void close_jitter_entropy_source(struct rng *ent_src)
close(pipefds[0]);
free(tdata);
free(threads);
+ free(aes_buf);
if (ossl_ctx) {
ossl_aes_exit(ossl_ctx);
ossl_ctx = NULL;
}
}
-
--
2.26.3