!72 【openEuler-24.03-LTS】Fix minor memory leak

From: @yixiangzhike 
Reviewed-by: @zcfsite 
Signed-off-by: @zcfsite
This commit is contained in:
openeuler-ci-bot 2024-10-08 01:25:23 +00:00 committed by Gitee
commit 8254eb1b76
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 52 additions and 1 deletions

View File

@ -0,0 +1,47 @@
From 95b9a31f81e4a56518269d2476b54a1f10fe8b3e Mon Sep 17 00:00:00 2001
From: Werner Koch <wk@gnupg.org>
Date: Fri, 27 Oct 2023 14:20:47 +0200
Subject: [PATCH] gpg: Fix minor memory leak during certain smartcard
operations.
* g10/keygen.c (card_store_key_with_backup): Fix memory leak on error.
---
g10/keygen.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/g10/keygen.c b/g10/keygen.c
index 87940722d..2f8528278 100644
--- a/g10/keygen.c
+++ b/g10/keygen.c
@@ -5386,17 +5386,26 @@ card_store_key_with_backup (ctrl_t ctrl, PKT_public_key *sub_psk,
{
ecdh_param_str = ecdh_param_str_from_pk (sk);
if (!ecdh_param_str)
- return gpg_error_from_syserror ();
+ {
+ free_public_key (sk);
+ return gpg_error_from_syserror ();
+ }
}
err = hexkeygrip_from_pk (sk, &hexgrip);
if (err)
- goto leave;
+ {
+ xfree (ecdh_param_str);
+ free_public_key (sk);
+ goto leave;
+ }
memset(&info, 0, sizeof (info));
rc = agent_scd_getattr ("SERIALNO", &info);
if (rc)
{
+ xfree (ecdh_param_str);
+ free_public_key (sk);
err = (gpg_error_t)rc;
goto leave;
}
--
2.33.0

View File

@ -1,6 +1,6 @@
Name: gnupg2
Version: 2.4.3
Release: 3
Release: 4
Summary: Utility for secure communication and data storage
License: GPLv3+
@ -19,6 +19,7 @@ Patch8: gnupg-2.2.21-coverity.patch
Patch9: gnupg2-revert-rfc4880bis.patch
Patch10: backport-dirmngr-Enable-the-call-of-ks_ldap_help_variables-wh.patch
Patch11: backport-gpg-Make-no-literal-work-again-for-c-and-store.patch
Patch12: backport-gpg-Fix-minor-memory-leak-during-certain-smartcard-o.patch
BuildRequires: gcc
BuildRequires: zlib-devel, npth-devel, texinfo
@ -120,6 +121,9 @@ make check
%changelog
* Mon Sep 30 2024 yixiangzhike <yixiangzhike007@163.com> - 2.4.3-4
- backport upstream patch to fix minor memory leak
* Wed Sep 25 2024 yixiangzhike <yixiangzhike007@163.com> - 2.4.3-3
- gpg Make --no-literal work again for -c and --store