-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: verify length and hashes of fetched bytes before parsing (#325)
* feat: add func to util for comparing raw bytes Add BytesMatchLenAndHashes() to verify that fetched bytes match the expected length and hashes. This is useful to check data before parsing. Signed-off-by: Joshua Lock <jlock@vmware.com> * fix: verify snapshot's len and hashes before parsing Signed-off-by: Joshua Lock <jlock@vmware.com> * fix: verify targets' len and hashes before parsing Signed-off-by: Joshua Lock <jlock@vmware.com> * feat: export version comparison utility function Signed-off-by: Joshua Lock <jlock@vmware.com> * fix: only check version after parsing fetched ss and ts We check the length and hashes of the fetched bytes before parsing them, therefore once the data are parsed into a FileMeta we only need to check against the expected version. The length and hashes checks are no longer required at this point, as they have already been done. Signed-off-by: Joshua Lock <jlock@vmware.com> * fix: remove spurious length check Signed-off-by: Joshua Lock <jlock@vmware.com> * chore: test newly exported util functions Add tests for newly exported functions in the util package: * VersionEqual() - simple test of version number comparison * BytesMatchLenAndHashes() - check function returns appropriate errors when incorrect length, hashes, or both are passed Signed-off-by: Joshua Lock <jlock@vmware.com>
- Loading branch information
Showing
3 changed files
with
125 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters