Repository navigation
Ignore ERROR-CODE reserved bits when decoding class - #286
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #286 +/- ##
=======================================
Coverage 66.43% 66.43%
=======================================
Files 27 27
Lines 2124 2124
=======================================
Hits 1411 1411
Misses 700 700
Partials 13 13
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
dngr2
force-pushed
the
errorcode-reserved-bits
branch
from
August 17, 2026 20:56
f9e0ec2 to
8dc92a3
Compare
The class byte holds a 3-bit Class in its low bits; the upper 5 are Reserved. RFC 5389 15.6 and RFC 8489 14.8 say receivers MUST ignore those bits, but GetFrom read the whole byte, so an ERROR-CODE with reserved bits set decoded to a wrong code (420 -> 22820) and could not be re-encoded. Mask with 0x7.
JoTurk
force-pushed
the
errorcode-reserved-bits
branch
from
August 18, 2026 12:55
8dc92a3 to
6bfea88
Compare
Member
|
I'll merge and tag this once the CI passes, somehow related pion/turn#581 :) |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The ERROR-CODE value's third byte holds a 3-bit Class in its low bits; the upper 5 bits are Reserved. RFC 5389 §15.6 (and RFC 8489 §14.8) say the Reserved bits SHOULD be 0 and receivers MUST ignore them.
GetFromread the entire byte as Class, so an ERROR-CODE arriving with reserved bits set decodes to a wrong code — e.g. class byte0xE4(low bits = 4) + number 20 should be420but decodes to22820— and a value the decoder accepts then failsAddTo(class > errorCodeClassMax), so the library can't re-emit what it just parsed. Masking the class with0x7fixes both. Number is genuinely 8 bits, so only the class byte needs masking. Added a test; full suite stays green.