Invalid buffer size safety check in org.bson.io.Bits.readFully(stream, buf, off, len)

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • 2.12.0, 3.0.0
    • Affects Version/s: 2.11.0
    • Component/s: BSON
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Test:
      call org.bson.io.Bits.readFully(new ByteArrayInputStream("some sample text".getBytes()), new byte[20], 0, 10);

      Expected:
      10 bytes are read.

      Observed:
      java.lang.IllegalArgumentException: Buffer is too small

      The safety check
      if (b.length - startOffset > length)

      { throw new IllegalArgumentException("Buffer is too small"); }

      should test for "<".

            Assignee:
            Unassigned
            Reporter:
            Carsten Haustein
            None
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: