Skip to content
Snippets Groups Projects
Commit d6dcc987 authored by Sébastien Blin's avatar Sébastien Blin
Browse files

misc: avoid crash if no certificate added for device

Using foundAccountDevice with a dht::PkId, can add known devices
without certificates. Iterating over knownDevices_ without checking
any certificate will lead to a segfault.
This will not happen under normal circumstances, because foundAccountDevice
only uses certificates, except for testing purpose

Change-Id: I9bf6682d7d6539c0f905e80995333db0d948c5af
parent dd83e5f7
No related branches found
No related tags found
No related merge requests found
...@@ -527,6 +527,10 @@ ArchiveAccountManager::syncDevices() ...@@ -527,6 +527,10 @@ ArchiveAccountManager::syncDevices()
// don't send sync data to ourself // don't send sync data to ourself
if (dev.first.toString() == info_->deviceId) if (dev.first.toString() == info_->deviceId)
continue; continue;
if (!dev.second.certificate) {
JAMI_WARNING("Cannot find certificate for {}", dev.first);
continue;
}
auto pk = dev.second.certificate->getSharedPublicKey(); auto pk = dev.second.certificate->getSharedPublicKey();
JAMI_DBG("sending device sync to %s %s", JAMI_DBG("sending device sync to %s %s",
dev.second.name.c_str(), dev.second.name.c_str(),
......
...@@ -595,6 +595,10 @@ ContactList::getSyncData() const ...@@ -595,6 +595,10 @@ ContactList::getSyncData() const
} }
for (const auto& dev : knownDevices_) { for (const auto& dev : knownDevices_) {
if (!dev.second.certificate) {
JAMI_WARNING("No certificate found for {}", dev.first);
continue;
}
sync_data.devices.emplace(dev.second.certificate->getLongId(), sync_data.devices.emplace(dev.second.certificate->getLongId(),
KnownDeviceSync {dev.second.name, KnownDeviceSync {dev.second.name,
dev.second.certificate->getId()}); dev.second.certificate->getId()});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment