Uploaded image for project: 'Apache Cassandra'
  1. Apache Cassandra
  2. CASSANDRA-1661

Use of ByteBuffer limit() must account for arrayOffset()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Fixed
    • 0.7 beta 3
    • None
    • None
    • Normal

    Description

      There are a few places in the code where it loops across a byte buffers backing array wrong:

      for (int i=bytes.position()bytes.arrayOffset(); i<bytes.limit(); i+)

      This is incorrect as the limit() does not account for arrayOffset()

      for (int i=bytes.position()bytes.arrayOffset(); i<bytes.limit()+bytes.arrayOffset(); i+)

      is the correct code.

      There is also a few places where the unit tests would fail if we used non wrapped byte arrays.

      Attachments

        1. 1661_v1.txt
          32 kB
          T Jake Luciani
        2. 1661_v2.txt
          149 kB
          T Jake Luciani

        Activity

          People

            tjake T Jake Luciani
            tjake T Jake Luciani
            T Jake Luciani
            Stu Hood
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: