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

Wrong checksum calculation in "quickfix.Field.getTotal()"

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.0
    • Fix Version/s: 1.6.0
    • Component/s: Engine
    • Environment:
      Java

      Description

      The "quickfix.Field.getTotal()" method computes the checksum with the following code:
      for (int i = 0; i < this.data.length(); ++i)

      { sum += this.data.charAt(i); }

      A problem arises if the returned character is written with more than 1 character.
      The checksum calculation must be done on "byte"s (the Quickfix specification)

      I wrote a correction:
      byte[] bytes = null;
      try {
      bytes = this.data.getBytes(CharsetSupport.getCharset());
      for (int i = 0; i < bytes.length; ++i)

      { sum += (((int) bytes[i]) & 0x00FF); }

      } catch (UnsupportedEncodingException e)

      { throw new RuntimeException(e); }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                amichair amichair
                Reporter:
                pantolomin John
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: