[gmime-devel] [PATCH 1/5] actually retrieve the session key



without advancing status by 11, we are fetching the string
'SESSION_KEY' instead of the actual session key.  Also, avoid memory
leaks in case gpg does something funny and emits multiple SESSION_KEY
lines during a single decryption (shouldn't happen).
---
 gmime/gmime-gpg-context.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gmime/gmime-gpg-context.c b/gmime/gmime-gpg-context.c
index e19603f..206126e 100644
--- a/gmime/gmime-gpg-context.c
+++ b/gmime/gmime-gpg-context.c
@@ -1341,6 +1341,9 @@ gpg_ctx_parse_status (struct _GpgCtx *gpg, GError **err)
                        } else if (!strncmp (status, "BADMDC", 6)) {
                                /* nothing to do, this will only be sent after DECRYPTION_FAILED */
                        } else if (!strncmp (status, "SESSION_KEY", 11)) {
+                               if (gpg->session_key)
+                                       g_free (gpg->session_key);
+                               status += 11;
                                status = next_token (status, TRUE, &gpg->session_key);
                        } else {
                                gpg_ctx_parse_signer_info (gpg, status);
-- 
2.10.2



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]