From 1ca3bbdaae51e453624e9924a6169a066ab314ba Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Fri, 30 Apr 2021 13:55:52 +0900 Subject: [PATCH] Fix for key attributes (long standing bug). Signed-off-by: NIIBE Yutaka --- ChangeLog | 6 ++++++ src/openpgp-do.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/ChangeLog b/ChangeLog index d7371b5..9e985b1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2021-04-30 NIIBE Yutaka + + * src/openpgp-do.c (rw_algorithm_attr): Fix writing algorithm + attribute, which may cause GC. Note that flash_enum_write needs + to call flash_enum_clear beforehand. + 2021-04-02 NIIBE Yutaka * VERSION: 1.2.18. diff --git a/src/openpgp-do.c b/src/openpgp-do.c index ce5b762..67b2d0b 100644 --- a/src/openpgp-do.c +++ b/src/openpgp-do.c @@ -815,6 +815,8 @@ rw_algorithm_attr (uint16_t tag, int with_tag, else if (algo == ALGO_RSA2K && *algo_attr_pp != NULL) { gpg_reset_algo_attr (kk); + /* Read it again, since GC may occur. */ + algo_attr_pp = get_algo_attr_pointer (kk); flash_enum_clear (algo_attr_pp); if (*algo_attr_pp != NULL) return 0; @@ -823,6 +825,10 @@ rw_algorithm_attr (uint16_t tag, int with_tag, (*algo_attr_pp != NULL && (*algo_attr_pp)[1] != algo)) { gpg_reset_algo_attr (kk); + /* Read it again, since GC may occur. */ + algo_attr_pp = get_algo_attr_pointer (kk); + if (*algo_attr_pp) + flash_enum_clear (algo_attr_pp); *algo_attr_pp = flash_enum_write (kk_to_nr (kk), algo); if (*algo_attr_pp == NULL) return 0;