fix(library/module): check for end-of-file in deserialization

This commit is contained in:
Gabriel Ebner 2017-06-21 11:07:03 +02:00
parent 942f7bf8b5
commit a0a70a678a

View file

@ -511,6 +511,10 @@ olean_data parse_olean(std::istream & in, std::string const & file_name, bool ch
code.resize(code_size);
d1.read(code);
if (!in.good()) {
throw exception(sstream() << "file '" << file_name << "' has been corrupted");
}
// if (m_senv.env().trust_lvl() <= LEAN_BELIEVER_TRUST_LEVEL) {
if (check_hash) {
unsigned computed_hash = olean_hash(code.data(), code_size);
@ -617,6 +621,9 @@ modification_list parse_olean_modifications(std::vector<char> const & olean_code
obj_counter++;
}
if (!in.good()) {
throw exception(sstream() << "file '" << file_name << "' has been corrupted");
}
return ms;
}