Details
Description
The begin string header will be incorrectly detected if a FIXT.1.1 message is fragmented at 12 bytes and a message will be lost with a message regarding bad message length.
/**
* Checks to see if the byte_buffer[buffer_offset] starts with data[]. The
* character ? is a one byte wildcard, lowercase letters are optional.
*
* @param pBuffer
* @param pBufferOffset
* @param pData
* @return
*/
public static int startsWith(ByteBuffer pBuffer, int pBufferOffset, byte[] pData) {
if (pBufferOffset + minMaskLength(pData) > pBuffer.limit()) {
return -1;
}
final int tInitOffset = pBufferOffset;
int tDataOffset = 0;
for (int tBufferLimit = pBuffer.limit();
(tDataOffset < pData.length) && (pBufferOffset < tBufferLimit);
tDataOffset++, pBufferOffset++)
{
if (pBuffer.get(pBufferOffset) != pData[tDataOffset] && pData[tDataOffset] != '?') {
// Now check for optional characters, at this point we know we didn't
// match, so we can just check to see if we failed a match on an optional character,
// and if so then just rewind the buffer one byte and keep going.
if (Character.toUpperCase(pData[tDataOffset]) == pBuffer.get(pBufferOffset)) {
continue;
}
// Didn't match the optional character, so act like it was not included and keep going
if (Character.isLetter(pData[tDataOffset]) && Character.isLowerCase(pData[tDataOffset])) {
--pBufferOffset;
continue;
}
return -1;
}
}
if (tDataOffset < pData.length) {
// the buffer was consumed but not the whole mask
return -1;
}
return pBufferOffset - tInitOffset;
}
Attachments
Issue Links
- relates to
-
QFJ-544 Header with BeginString=FIXT.1.1 incorrectly parsed by FIXMessageDecoder (manifests as missing messages)
-
- Resolved
-