1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Merge pull request #1823 from H3rnand3zzz/fix/msg-crash

Fix memory corruption crash
This commit is contained in:
Michael Vetter 2023-04-14 13:14:01 +02:00 committed by GitHub
commit a99a4fad3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 deletions

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

View File

@ -419,10 +419,12 @@ p_ox_gpg_decrypt(char* base64)
size_t len;
char* plain_str = gpgme_data_release_and_get_mem(plain, &len);
char* result = malloc(len + 1);
memcpy(result, plain_str, len);
result[len] = '\0';
gpgme_free(plain_str);
char* result = NULL;
if (plain_str) {
result = strndup(plain_str, len);
gpgme_free(plain_str);
}
return result;
}