Skip to content

Commit a6b5645

Browse files
committed
make lookup_pgp_contact_by_fingerprint safer
1 parent 8adce32 commit a6b5645

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/receive_imf.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3646,11 +3646,16 @@ async fn lookup_pgp_contact_by_fingerprint(
36463646
context: &Context,
36473647
fingerprint: &str,
36483648
) -> Result<Option<ContactId>> {
3649+
debug_assert!(!fingerprint.is_empty());
3650+
if fingerprint.is_empty() {
3651+
// Avoid accidentally looking up a non-PGP contact.
3652+
return Ok(None);
3653+
}
36493654
if let Some(contact_id) = context
36503655
.sql
36513656
.query_row_optional(
36523657
"SELECT id FROM contacts
3653-
WHERE contacts.fingerprint=?",
3658+
WHERE fingerprint=? AND fingerprint!=''",
36543659
(fingerprint,),
36553660
|row| {
36563661
let contact_id: ContactId = row.get(0)?;

0 commit comments

Comments
 (0)