fix: Boundary condition error in VerifyStream #509
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #507
Tests exist that push a single byte at a time.
This will hit every boundary condition.
However this is not complete enough.
State can be reset as the code transitions
from one boundary condition to another.
The prime example of this problem
the
VerifyStream
.It has 4 boundary in the
_transform
function.The body header, the body, the auth tag, and signature.
By sending 1 byte
as the code transitions from the body header
to the body
the code handling the exiting
of the body header has no way to interact
with the body,
because the 1 byte of data
completely isolates these code branches.
In this case the code was buffering
the body header in
frameBuffer
but when exiting this section
and passing control to
the actual content section,
it used the
chunk
to form the tail.When passing a single byte,
this tail would always be empty,
because it would have been incorporated
into the frame header.
Adding tests to span
the boundary conditions
to verify both this fix
and that there are not other lurking.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Check any applicable: