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:
@@ -721,10 +721,9 @@ p_gpg_decrypt(const char* const cipher)
|
|||||||
char* plain_str = gpgme_data_release_and_get_mem(plain_data, &len);
|
char* plain_str = gpgme_data_release_and_get_mem(plain_data, &len);
|
||||||
char* result = NULL;
|
char* result = NULL;
|
||||||
if (plain_str) {
|
if (plain_str) {
|
||||||
plain_str[len] = 0;
|
result = strndup(plain_str, len);
|
||||||
result = g_strdup(plain_str);
|
gpgme_free(plain_str);
|
||||||
}
|
}
|
||||||
gpgme_free(plain_str);
|
|
||||||
|
|
||||||
if (passphrase_attempt) {
|
if (passphrase_attempt) {
|
||||||
passphrase = strdup(passphrase_attempt);
|
passphrase = strdup(passphrase_attempt);
|
||||||
|
|||||||
Reference in New Issue
Block a user