-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: prevent panics in decrypt_full_set and decrypt_range
This commit fixes potential panic conditions in the decryption functions and improves their robustness and clarity: - Replace unsafe direct indexing with safe `.get()` lookups in chunk hash validation - Add proper error handling for missing or corrupted chunks - Rename `relative_pos` parameter to `file_pos` to clarify its meaning - Add comprehensive documentation for function parameters and return values - Improve error messages to aid in debugging missing/corrupted chunks - Maintain consistent error handling throughout both functions The changes prevent runtime panics that could occur when: - A chunk's content hash doesn't match any expected hash in the data map - Chunks are missing or corrupted - Invalid chunk indices are encountered This is a breaking change for `decrypt_range()` as the `relative_pos` parameter has been renamed to `file_pos` to better reflect that it represents a position within the complete file rather than within the first chunk. Testing: - Existing tests pass - Added error cases are properly handled - API documentation is complete and accurate
- Loading branch information
Showing
1 changed file
with
54 additions
and
27 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