bugfix: handle malformed/old-format negentropy messages gracefully

This commit is contained in:
Doug Hoyte
2023-09-22 14:38:31 -04:00
parent a7aefde56c
commit c9254adaf8
2 changed files with 43 additions and 5 deletions

View File

@ -126,7 +126,14 @@ void cmd_sync(const std::vector<std::string> &subArgs) {
if (msg.at(0) == "NEG-MSG") {
uint64_t origHaves = have.size(), origNeeds = need.size();
auto neMsg = ne.reconcile(from_hex(msg.at(2).get_string()), have, need);
std::optional<std::string> neMsg;
try {
neMsg = ne.reconcile(from_hex(msg.at(2).get_string()), have, need);
} catch (std::exception &e) {
LE << "Unable to parse negentropy message from relay: " << e.what();
doExit(1);
}
totalHaves += have.size() - origHaves;
totalNeeds += need.size() - origNeeds;