[gmime-devel] [PATCH] Scrub the session key from RAM where possible



We won't need the session key after this copy, so we should get rid of
it in case the slice gets reused.
---
 gmime/gmime-gpg-context.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gmime/gmime-gpg-context.c b/gmime/gmime-gpg-context.c
index 74f8a4e..43059ff 100644
--- a/gmime/gmime-gpg-context.c
+++ b/gmime/gmime-gpg-context.c
@@ -1338,7 +1338,11 @@ 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)) {
+                               char *begin = status;
                                status = next_token (status, &gpg->session_key);
+                               /* scrub the session key from RAM */
+                               if (status > begin)
+                                       memset (begin, 'X', status - begin);
                        } 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]