[QFJ-687] Lost message on package fragmentation at 12 bytes in a FIXT.1.1 message Created: 12/Jun/12 Updated: 04/Sep/12 Resolved: 04/Sep/12 |
|
| Status: | Closed |
| Project: | QuickFIX/J |
| Component/s: | Engine |
| Affects Version/s: | 1.5.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Default |
| Reporter: | Jonas Fügedi | Assignee: | Unassigned |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | encoding | ||
| Issue Links: |
|
||||||||
| 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;
}
|
| Comments |
| Comment by Jonas Fügedi [ 12/Jun/12 ] |
|
The code provided shows my fix where if the whole mask is not consumed then -1 is returned |
| Comment by Jonas Fügedi [ 12/Jun/12 ] |
|
Oops, copy paste bug... the variable names are wrong, won't compile
if (dataOffset < data.length) {
// the buffer was consumed but not the whole mask
return -1;
}
|
| Comment by Christoph John [ 15/Aug/12 ] |
|
This looks like |
| Comment by Jonas Fügedi [ 20/Aug/12 ] |
|
Yes, |
| Comment by Christoph John [ 20/Aug/12 ] |
|
Sorry, I do not understand fully. Thanks |
| Comment by Jonas Fügedi [ 03/Sep/12 ] |
|
This can be closed, the |