Don't crash when the deserialization of an error message fails
Found while scanning the code of an open source project related to onions.
This commit is contained in:
parent
193645318b
commit
36bcefc39d
|
@ -148,6 +148,9 @@ bool ErrorLogger::ErrorMessage::deserialize(const std::string &data)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (results.size() != 4)
|
||||||
|
throw InternalError(0, "Internal Error: Deserialization of error message failed");
|
||||||
|
|
||||||
_id = results[0];
|
_id = results[0];
|
||||||
_severity = Severity::fromString(results[1]);
|
_severity = Severity::fromString(results[1]);
|
||||||
_shortMessage = results[2];
|
_shortMessage = results[2];
|
||||||
|
|
|
@ -53,6 +53,7 @@ private:
|
||||||
|
|
||||||
// Serialize / Deserialize inconclusive message
|
// Serialize / Deserialize inconclusive message
|
||||||
TEST_CASE(SerializeInconclusiveMessage);
|
TEST_CASE(SerializeInconclusiveMessage);
|
||||||
|
TEST_CASE(DeserializeInvalidInput);
|
||||||
|
|
||||||
TEST_CASE(suppressUnmatchedSuppressions);
|
TEST_CASE(suppressUnmatchedSuppressions);
|
||||||
}
|
}
|
||||||
|
@ -260,6 +261,11 @@ private:
|
||||||
ASSERT_EQUALS("Programming error", msg2.verboseMessage());
|
ASSERT_EQUALS("Programming error", msg2.verboseMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeserializeInvalidInput() const {
|
||||||
|
ErrorMessage msg;
|
||||||
|
ASSERT_THROW(msg.deserialize("500foobar"), InternalError);
|
||||||
|
}
|
||||||
|
|
||||||
void suppressUnmatchedSuppressions() {
|
void suppressUnmatchedSuppressions() {
|
||||||
std::list<Suppressions::SuppressionEntry> suppressions;
|
std::list<Suppressions::SuppressionEntry> suppressions;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue