Uploaded image for project: 'MINA'
  1. MINA
  2. DIRMINA-664

EMPTY_* IoBuffer constants can be made mutable and cause data errors

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0.0-M4
    • 2.0.0-M5
    • Core
    • None
    • All?

    Description

      The EMPTY_* constants in the IoBuffer class can be made mutable (by using the setAutoExpand(true) method call) which can result in those constant buffers no longer being empty. This can obviously cause a multitude of data errors.

      See this JUnit test case for an example:

      import junit.framework.TestCase;

      import org.apache.mina.core.buffer.IoBuffer;

      public class TestIoBuffer extends TestCase {

      public void testIoBufferAllocate()

      { IoBuffer buf = IoBuffer.allocate(0).setAutoExpand(true); buf.putInt(1234); buf.flip(); buf = IoBuffer.allocate(0); assertEquals(0, buf.remaining()); }

      public void testEmptyIoBuffer()

      { IoBuffer buf = IoBuffer.EMPTY_BUFFER.setAutoExpand(true); buf.putInt(1234); buf.flip(); buf = IoBuffer.EMPTY_BUFFER; assertEquals(0, buf.remaining()); }

      }

      Attachments

        Activity

          People

            elecharny Emmanuel Lécharny
            darose David Rosenstrauch
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: