From 2b20ff62fc8c5fbb73d0c796f69edd063edccf33 Mon Sep 17 00:00:00 2001 From: PiotrBzdrega Date: Sun, 11 Feb 2024 01:56:45 +0100 Subject: [PATCH 1/5] move entropy init prior arguments number recognition Signed-off-by: PiotrBzdrega --- programs/pkey/gen_key.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/programs/pkey/gen_key.c b/programs/pkey/gen_key.c index 6914c9390..26453cc95 100644 --- a/programs/pkey/gen_key.c +++ b/programs/pkey/gen_key.c @@ -248,7 +248,7 @@ int main(int argc, char *argv[]) mbedtls_mpi_init(&D); mbedtls_mpi_init(&E); mbedtls_mpi_init(&DP); mbedtls_mpi_init(&DQ); mbedtls_mpi_init(&QP); #endif /* MBEDTLS_RSA_C */ - + mbedtls_entropy_init(&entropy); mbedtls_pk_init(&key); mbedtls_ctr_drbg_init(&ctr_drbg); memset(buf, 0, sizeof(buf)); @@ -336,7 +336,6 @@ usage: mbedtls_printf("\n . Seeding the random number generator..."); fflush(stdout); - mbedtls_entropy_init(&entropy); #if !defined(_WIN32) && defined(MBEDTLS_FS_IO) if (opt.use_dev_random) { if ((ret = mbedtls_entropy_add_source(&entropy, dev_random_entropy_poll, From f6a9cfa5d201cc588171fe879577c57a26b58b2a Mon Sep 17 00:00:00 2001 From: PiotrBzdrega Date: Sun, 11 Feb 2024 09:41:56 +0100 Subject: [PATCH 2/5] adjust indentation Signed-off-by: PiotrBzdrega --- programs/pkey/gen_key.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/programs/pkey/gen_key.c b/programs/pkey/gen_key.c index 26453cc95..194a5cbba 100644 --- a/programs/pkey/gen_key.c +++ b/programs/pkey/gen_key.c @@ -248,7 +248,8 @@ int main(int argc, char *argv[]) mbedtls_mpi_init(&D); mbedtls_mpi_init(&E); mbedtls_mpi_init(&DP); mbedtls_mpi_init(&DQ); mbedtls_mpi_init(&QP); #endif /* MBEDTLS_RSA_C */ - mbedtls_entropy_init(&entropy); + + mbedtls_entropy_init(&entropy); mbedtls_pk_init(&key); mbedtls_ctr_drbg_init(&ctr_drbg); memset(buf, 0, sizeof(buf)); From 7238efd13689316d8fc3ef772333a5b0a438d227 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Bzdr=C4=99ga?= Date: Mon, 12 Feb 2024 21:06:54 +0100 Subject: [PATCH 3/5] changelog for bugfix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Piotr Bzdręga --- ChangeLog.d/gen-key-segfault.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 ChangeLog.d/gen-key-segfault.txt diff --git a/ChangeLog.d/gen-key-segfault.txt b/ChangeLog.d/gen-key-segfault.txt new file mode 100644 index 000000000..7f8c39b09 --- /dev/null +++ b/ChangeLog.d/gen-key-segfault.txt @@ -0,0 +1,3 @@ +Bugfix + * Avoid segmentation fault caused by releasing not initialized + entropy resource in gen_key example. Fixes #8809 \ No newline at end of file From e0a6f7d32007836ba25af15f279b277a6f5915df Mon Sep 17 00:00:00 2001 From: PiotrBzdrega Date: Tue, 13 Feb 2024 17:08:40 +0100 Subject: [PATCH 4/5] fill out missing dot in changelog Signed-off-by: PiotrBzdrega --- ChangeLog.d/gen-key-segfault.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.d/gen-key-segfault.txt b/ChangeLog.d/gen-key-segfault.txt index 7f8c39b09..4fb2d1f85 100644 --- a/ChangeLog.d/gen-key-segfault.txt +++ b/ChangeLog.d/gen-key-segfault.txt @@ -1,3 +1,3 @@ Bugfix * Avoid segmentation fault caused by releasing not initialized - entropy resource in gen_key example. Fixes #8809 \ No newline at end of file + entropy resource in gen_key example. Fixes #8809. \ No newline at end of file From dc6606b5e3ecc8ea14edadbbf47fb2da7b2bd88c Mon Sep 17 00:00:00 2001 From: PiotrBzdrega Date: Tue, 13 Feb 2024 22:17:08 +0100 Subject: [PATCH 5/5] newline at end of changelog file Signed-off-by: PiotrBzdrega --- ChangeLog.d/gen-key-segfault.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.d/gen-key-segfault.txt b/ChangeLog.d/gen-key-segfault.txt index 4fb2d1f85..fefc70272 100644 --- a/ChangeLog.d/gen-key-segfault.txt +++ b/ChangeLog.d/gen-key-segfault.txt @@ -1,3 +1,3 @@ Bugfix * Avoid segmentation fault caused by releasing not initialized - entropy resource in gen_key example. Fixes #8809. \ No newline at end of file + entropy resource in gen_key example. Fixes #8809.