Commit bcdfa234 authored by Sandro Knauß's avatar Sandro Knauß 🐝
Browse files

Do not rely on existance of Message-ID header.

There may be mails without any Message-ID header and those mails trigger
a segfault.
parent 53343c53
......@@ -66,10 +66,15 @@ void MessageCore::processAutocryptfromMail(const HeaderMixupNodeHelper &mixup)
{
auto storage = AutocryptStorage::self();
QByteArray messageid = "<NO Message-ID header>";
if (mixup.mailHeaderAsBase("Message-ID")) {
messageid = mixup.mailHeaderAsBase("Message-ID")->as7BitString(false);
}
const auto fromAddr = mixup.mailHeaderAsAddressList("from");
if (fromAddr->addresses().size() != 1) {
qInfo(AUTOCRYPT_LOG) << "Don't update Autocrypt storage, because we have multiple From addresses found in "
<< mixup.mailHeaderAsBase("Message-ID")->as7BitString(false);
qInfo(AUTOCRYPT_LOG) << "Don't update Autocrypt storage, none or multiple From headers found in "
<< messageid;
return;
}
......@@ -109,17 +114,17 @@ void MessageCore::processAutocryptfromMail(const HeaderMixupNodeHelper &mixup)
auto recipient = storage->addRecipient(params.value("addr"));
recipient->updateFromMessage(mixup, header);
qInfo(AUTOCRYPT_LOG) << "Update Autocrypt information for " << recipient->addr() << " from "
<< mixup.mailHeaderAsBase("Message-ID")->as7BitString(false);
<< messageid;
} else {
qInfo(AUTOCRYPT_LOG) << "Don't update Autocrypt storage, because we have multiple valid Autocrypt headers found in "
<< mixup.mailHeaderAsBase("Message-ID")->as7BitString(false);
<< messageid;
}
} else {
auto recipient = storage->getRecipient(fromAddr->addresses().value(0));
if (recipient) {
recipient->updateFromMessage(mixup, nullptr);
qInfo(AUTOCRYPT_LOG) << "Update Autocrypt information for " << recipient->addr() << " from "
<< mixup.mailHeaderAsBase("Message-ID")->as7BitString(false);
<< messageid;
}
}
......@@ -137,7 +142,7 @@ void MessageCore::processAutocryptfromMail(const HeaderMixupNodeHelper &mixup)
auto recipient = storage->addRecipient(params.value("addr"));
recipient->updateFromGossip(mixup, header);
qInfo(AUTOCRYPT_LOG) << "Update Autocrypt Gossip information for" << recipient->addr() << " from "
<< mixup.mailHeaderAsBase("Message-ID")->as7BitString(false);
<< messageid;
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment