mirror of
https://github.com/AGWA/git-crypt.git
synced 2025-12-05 20:40:05 -08:00
Raise an error if legacy key file has trailing data
This commit is contained in:
7
key.cpp
7
key.cpp
@@ -117,6 +117,13 @@ void Key_file::Entry::load_legacy (uint32_t arg_version, std::istream& in)
|
|||||||
if (in.gcount() != HMAC_KEY_LEN) {
|
if (in.gcount() != HMAC_KEY_LEN) {
|
||||||
throw Malformed();
|
throw Malformed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (in.peek() != -1) {
|
||||||
|
// Trailing data is a good indication that we are not actually reading a
|
||||||
|
// legacy key file. (This is important to check since legacy key files
|
||||||
|
// did not have any sort of file header.)
|
||||||
|
throw Malformed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Key_file::Entry::store (std::ostream& out) const
|
void Key_file::Entry::store (std::ostream& out) const
|
||||||
|
|||||||
Reference in New Issue
Block a user