Uploaded image for project: 'QuickFIX/J'
  1. QuickFIX/J
  2. QFJ-687

Lost message on package fragmentation at 12 bytes in a FIXT.1.1 message

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Default
    • Resolution: Duplicate
    • Affects Version/s: 1.5.2
    • Fix Version/s: None
    • Component/s: Engine
    • Labels:

      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

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                jonas.fugedi@cinnober.com Jonas Fügedi
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: