Thanks to visit codestin.com
Credit goes to github.com

Skip to content

io/Unsigned*.java type conversion fixes#416

Merged
mondain merged 1 commit intoRed5:mainfrom
kdkd:cherry-pick-7f006fa-20251126-135230
Nov 26, 2025
Merged

io/Unsigned*.java type conversion fixes#416
mondain merged 1 commit intoRed5:mainfrom
kdkd:cherry-pick-7f006fa-20251126-135230

Conversation

@kdkd
Copy link

@kdkd kdkd commented Nov 26, 2025

Commit from kdkd fork 7f006fa

io/object/Unsigned*.java:

UnsignedShort equals accepts any Number but immediately casts to UnsignedNumber, so comparing to Integer, Long,
etc. throws ClassCastException, breaking equality contracts and callers that use boxed primitives.

UnsignedInt fromBytes(byte[] c, int idx) ignores idx and shifts raw signed bytes without masking. Any non-zero
offset or byte with the high bit set returns a corrupted value, so parsing multi-value buffers yields wrong integers.

UnsignedShort Same offset/sign issue: ignores idx and shifts signed bytes, producing wrong values for offset reads
or bytes >=0x80.

UnsignedByte Also ignores the supplied idx and always reads c[0], so attempting to parse from a specific buffer
offset returns the wrong byte.


UnsignedShort equals accepts any Number but immediately casts to UnsignedNumber, so comparing to Integer, Long,
etc. throws ClassCastException, breaking equality contracts and callers that use boxed primitives.

UnsignedInt fromBytes(byte[] c, int idx) ignores idx and shifts raw signed bytes without masking. Any non-zero
offset or byte with the high bit set returns a corrupted value, so parsing multi-value buffers yields wrong integers.

UnsignedShort Same offset/sign issue: ignores idx and shifts signed bytes, producing wrong values for offset reads
or bytes >=0x80.

UnsignedByte Also ignores the supplied idx and always reads c[0], so attempting to parse from a specific buffer
offset returns the wrong byte.
@mondain mondain merged commit 986256a into Red5:main Nov 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants