From 5e8f1f9c853eff2fe49cc7f1dadb285b3c337c18 Mon Sep 17 00:00:00 2001 From: John Hernandez <129467592+H3rnand3zzz@users.noreply.github.com> Date: Thu, 13 Apr 2023 10:14:54 +0200 Subject: Fix memory corruption crash Under certain circumstances setting plain_str[len] to 0 might lead to crash and it does not follow the best practices as well. This change allows better handling of buffer copying and prevents crash. --- src/pgp/gpg.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/pgp/gpg.c') diff --git a/src/pgp/gpg.c b/src/pgp/gpg.c index 8762660d..3ef69c1d 100644 --- a/src/pgp/gpg.c +++ b/src/pgp/gpg.c @@ -721,10 +721,9 @@ p_gpg_decrypt(const char* const cipher) char* plain_str = gpgme_data_release_and_get_mem(plain_data, &len); char* result = NULL; if (plain_str) { - plain_str[len] = 0; - result = g_strdup(plain_str); + result = strndup(plain_str, len); + gpgme_free(plain_str); } - gpgme_free(plain_str); if (passphrase_attempt) { passphrase = strdup(passphrase_attempt); -- cgit 1.4.1-2-gfad0 '> summary refs log blame commit diff stats
path: root/make_doc.py
blob: d59ac73bc70e0d085726ab90a1c5f6bf446b1440 (plain) (tree)
1
2
3
4
5
6
7
8