This is an automated email from the ASF dual-hosted git repository.
tabish121 pushed a commit to branch 1.x
in repository https://gitbox.apache.org/repos/asf/qpid-protonj2.git
The following commit(s) were added to refs/heads/1.x by this push:
new 24633b50 PROTON-3001 Fix read of Sym8 Symbols from the SASL stream
decoder
24633b50 is described below
commit 24633b509833f9f911532909f5d6c204ee48a336
Author: Timothy Bish <[email protected]>
AuthorDate: Tue Nov 3 18:08:27 2026 -0500
PROTON-3001 Fix read of Sym8 Symbols from the SASL stream decoder
Correctly mask the size byte when casting to int on the read from the
SASL decoder to avoid a decode exception
(cherry picked from commit 86df861d222503850835ae355933fc103ce4b795)
---
.../primitives/SaslSymbol8TypeDecoder.java | 2 +-
.../codec/primitives/SymbolTypeCodecTest.java | 39 ++++++++++++++++++++++
2 files changed, 40 insertions(+), 1 deletion(-)
diff --git
a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/primitives/SaslSymbol8TypeDecoder.java
b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/primitives/SaslSymbol8TypeDecoder.java
index 1ed56b6e..64ceb96f 100644
---
a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/primitives/SaslSymbol8TypeDecoder.java
+++
b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/primitives/SaslSymbol8TypeDecoder.java
@@ -48,7 +48,7 @@ public final class SaslSymbol8TypeDecoder extends
AbstractSymbolTypeDecoder {
@Override
public int readSize(InputStream stream, StreamDecoderState state) throws
DecodeException {
- return ProtonStreamUtils.readByte(stream);
+ return ProtonStreamUtils.readByte(stream) & 0xff;
}
@Override
diff --git
a/protonj2/src/test/java/org/apache/qpid/protonj2/codec/primitives/SymbolTypeCodecTest.java
b/protonj2/src/test/java/org/apache/qpid/protonj2/codec/primitives/SymbolTypeCodecTest.java
index 40018ebb..800c5403 100644
---
a/protonj2/src/test/java/org/apache/qpid/protonj2/codec/primitives/SymbolTypeCodecTest.java
+++
b/protonj2/src/test/java/org/apache/qpid/protonj2/codec/primitives/SymbolTypeCodecTest.java
@@ -752,4 +752,43 @@ public class SymbolTypeCodecTest extends CodecTestSupport {
assertEquals(bytes, buffer);
}
+
+ @Test
+ public void testDecodeSASLSymbol8WithFullSizeEncoded() throws IOException {
+ doTestDecodeSASLSymbol8WithFullSizeEncoded(false);
+ }
+
+ @Test
+ public void testDecodeSASLSymbol8WithFullSizeEncodedFS() throws
IOException {
+ doTestDecodeSASLSymbol8WithFullSizeEncoded(true);
+ }
+
+ private void doTestDecodeSASLSymbol8WithFullSizeEncoded(boolean
fromStream) throws IOException {
+ ProtonBuffer buffer =
ProtonBufferAllocator.defaultAllocator().allocate();
+
+ final byte[] payload = new byte[255];
+
+ random.nextBytes(payload);
+
+ buffer.writeByte(EncodingCodes.SYM8);
+ buffer.writeByte((byte) 255);
+ buffer.writeBytes(payload);
+
+ final Symbol result;
+
+ if (fromStream) {
+ InputStream stream = new ProtonBufferInputStream(buffer.copy());
+ result = saslStreamDecoder.readSymbol(stream,
saslStreamDecoderState);
+ } else {
+ result = saslDecoder.readSymbol(buffer.copy(), saslDecoderState);
+ }
+
+ buffer.advanceReadOffset(2); // Skip the encoding code and size
+
+ final ProtonBuffer bytes =
ProtonBufferAllocator.defaultAllocator().allocate();
+
+ result.writeTo(bytes);
+
+ assertEquals(bytes, buffer);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]