Add extra check for uid_hint to make sure it never overflows

This commit is contained in:
Jakub Zelenka 2025-04-08 11:17:28 +02:00
parent 312655c7ce
commit c839aa56e1
No known key found for this signature in database
GPG key ID: 1C0779DC5C0A9DE4

View file

@ -692,10 +692,10 @@ gpgme_error_t passphrase_cb(
GNUPG_ERR("Incorrent passphrase");
return 1;
}
for (idx=0; idx < 16; idx++) {
for (idx=0; idx < 16 && uid_hint[idx] != '\0'; idx++) {
uid[idx] = uid_hint[idx];
}
uid[16] = '\0';
uid[idx] = '\0';
if (!PHPC_HASH_CSTR_FIND_PTR_IN_COND(
PHPC_THIS->signkeys, (char *)uid, passphrase)) {
GNUPG_ERR("no passphrase set");
@ -736,10 +736,10 @@ gpgme_error_t passphrase_decrypt_cb (
GNUPG_ERR("No user ID hint");
return 1;
}
for (idx=0; idx < 16; idx++) {
for (idx=0; idx < 16 && uid_hint[idx] != '\0'; idx++) {
uid[idx] = uid_hint[idx];
}
uid[16] = '\0';
uid[idx] = '\0';
if (!PHPC_HASH_CSTR_FIND_PTR_IN_COND(
PHPC_THIS->decryptkeys, (char *)uid, passphrase)) {
GNUPG_ERR("no passphrase set");