1
0
mirror of https://github.com/profanity-im/profanity.git synced 2025-01-03 14:57:42 -05:00

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.
This commit is contained in:
John Hernandez 2023-04-13 10:14:54 +02:00
parent 766dc76e33
commit 5e8f1f9c85

View File

@ -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);