@@ -1793,6 +1793,7 @@ private final String _handleLongFieldName() throws IOException
1793
1793
if (quads >= _quadBuffer .length ) {
1794
1794
_quadBuffer = _growArrayTo (_quadBuffer , _quadBuffer .length + 256 );
1795
1795
}
1796
+ q = _padLastQuad (q , bytes );
1796
1797
_quadBuffer [quads ++] = q ;
1797
1798
byteLen += bytes ;
1798
1799
}
@@ -1825,7 +1826,7 @@ private final String _findDecodedFromSymbols(final int len) throws IOException
1825
1826
if (len < 5 ) {
1826
1827
int inPtr = _inputPtr ;
1827
1828
final byte [] inBuf = _inputBuffer ;
1828
- int q = inBuf [inPtr ] & 0xFF ;
1829
+ int q = _padQuadForNulls ( inBuf [inPtr ]) ;
1829
1830
if (len > 1 ) {
1830
1831
q = (q << 8 ) + (inBuf [++inPtr ] & 0xFF );
1831
1832
if (len > 2 ) {
@@ -1849,7 +1850,7 @@ private final String _findDecodedFromSymbols(final int len) throws IOException
1849
1850
q1 = (q1 << 8 ) | (inBuf [inPtr ++] & 0xFF );
1850
1851
1851
1852
if (len < 9 ) {
1852
- int q2 = (inBuf [inPtr ++] & 0xFF );
1853
+ int q2 = _padQuadForNulls (inBuf [inPtr ++]);
1853
1854
int left = len - 5 ;
1854
1855
if (left > 0 ) {
1855
1856
q2 = (q2 << 8 ) + (inBuf [inPtr ++] & 0xFF );
@@ -1871,7 +1872,7 @@ private final String _findDecodedFromSymbols(final int len) throws IOException
1871
1872
q2 = (q2 << 8 ) | (inBuf [inPtr ++] & 0xFF );
1872
1873
1873
1874
if (len < 13 ) {
1874
- int q3 = (inBuf [inPtr ++] & 0xFF );
1875
+ int q3 = _padQuadForNulls (inBuf [inPtr ++]);
1875
1876
int left = len - 9 ;
1876
1877
if (left > 0 ) {
1877
1878
q3 = (q3 << 8 ) + (inBuf [inPtr ++] & 0xFF );
@@ -1920,7 +1921,7 @@ private final String _findDecodedFixed12(int len, int q1, int q2) throws IOExcep
1920
1921
} while ((len -= 4 ) > 3 );
1921
1922
// and then leftovers
1922
1923
if (len > 0 ) {
1923
- int q = inBuf [inPtr ] & 0xFF ;
1924
+ int q = _padQuadForNulls ( inBuf [inPtr ]) ;
1924
1925
if (len > 1 ) {
1925
1926
q = (q << 8 ) + (inBuf [++inPtr ] & 0xFF );
1926
1927
if (len > 2 ) {
@@ -1940,13 +1941,15 @@ private static int[] _growArrayTo(int[] arr, int minSize) {
1940
1941
return Arrays .copyOf (arr , size );
1941
1942
}
1942
1943
1943
- // Helper method needed to fix [dataformats-binary#312], masking of 0x00 character
1944
- // 26-Feb-2022, tatu: not yet used
1945
- /*
1944
+ // Helper methods needed to fix [dataformats-binary#312], masking of 0x00 character
1945
+
1946
1946
private final static int _padLastQuad (int q , int bytes ) {
1947
1947
return (bytes == 4 ) ? q : (q | (-1 << (bytes << 3 )));
1948
1948
}
1949
- */
1949
+
1950
+ private final static int _padQuadForNulls (int firstByte ) {
1951
+ return (firstByte & 0xFF ) | 0xFFFFFF00 ;
1952
+ }
1950
1953
1951
1954
/*
1952
1955
/**********************************************************
0 commit comments