Skip to content

Conversation

@rklaehn
Copy link
Collaborator

@rklaehn rklaehn commented Apr 14, 2025

The new hazmat API is more strict than the previous guts api when it comes to incorrect use of the Hasher.

This exposed a bug that previously led to the exact expected behaviour. When the remote stops sending data, e.g. because of the data being invalid, you could get a read of size 0. Feeding this blob into the hasher with is_root set to false would before just produce a wrong hash - correctly causing the data to be rejected.

Now it triggers an assertion, because hashing an empty blob with is_root set to false can never be correct.

With this change we make sure to bail out immediately with an io error when there is a short read, instead of feeding the data to the hasher.

@n0bot n0bot bot added this to iroh Apr 14, 2025
@github-project-automation github-project-automation bot moved this to 🏗 In progress in iroh Apr 14, 2025
@rklaehn rklaehn merged commit 2e03cf9 into main Apr 14, 2025
26 checks passed
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in iroh Apr 14, 2025
@rklaehn rklaehn deleted the read-exact branch April 14, 2025 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

2 participants