Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4892631

JPEG ImageReader does not validate the image indices with respect to Min Index

XMLWordPrintable

    • generic, arm
    • generic, linux

      The API doc for reader.getWidth(), getHeight(), read() and getAspectRatio() claims that the above methods must throw an IndexOutOfBoundsException when the given image index is invalid. This seems to work fine for the read method. But for other methods, when the given index is less than 0 (or less than Min Index) no validation take place. The aspect ratio is returned as 'NaN' and width, height are 0. Actually the JPEG ImageReader must validate the image index on the positive as well as negative sides as GIF reader does. Hence it must throw an exception when the image index is less than 0 and this happens fine in the case of read method where the given index is validated against the min index.

      This is reproducible since JDK1.4+ on win32 as well as Solaris platforms.

      I have attached a sample code. Execute the sample code and pass the image file as follows:
      java ImageReaderTest flower.jpg
      if you don't see any exception then the bug is reproduced. Try with other image types such as GIF and compare the behavior.

            Unassigned Unassigned
            pmohansunw Praveen Mohan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: