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

"Corrupt JPEG data: premature end of data segment" error not thrown

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.4.0
    • client-libs
    • 2d
    • sparc
    • solaris_8



      Name: bsT130419 Date: 10/05/2001


      java version "1.4.0-beta2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta2-b77)
      Java HotSpot(TM) Client VM (build 1.4.0-beta2-b77, mixed mode)


      Running the following code on a corrupted jpeg results in an error message
      writen on std err output by JPEGCodec.decodeAsBufferedImage, but no exception
      is thrown and no validity flag of the resulting JPEGDecodeParam allow the code
      to actually detect there ever was a corruption. This flaw introduces corrupted
      data in our flow.

      Execution:
      bash-2.03$ ./java draw XXX30_28.jpg
      Corrupt JPEG data: premature end of data segment
      ##### Params -> isImageInfoValid=trueisTableInfoValid=true
      bash-2.03$

      Code:
      import java.io.*;
      import java.awt.*;
      import java.awt.image.*;
      import com.sun.image.codec.jpeg.*;

      public class draw
      {
      public static void main(String args[]) throws Exception
      {
      try
      {
               InputStream fis = null;
               JPEGImageDecoder decoder = null;
               BufferedImage bi = null;
                          long stamp = System.currentTimeMillis();
      fis = new FileInputStream(args[0]);
               decoder = JPEGCodec.createJPEGDecoder(fis);
               JPEGDecodeParam p=decoder.getJPEGDecodeParam();
               PrintStream olderr = System.err;
               bi = decoder.decodeAsBufferedImage();
               p=decoder.getJPEGDecodeParam();
               if (p!=null)
               System.out.println("##### Params ->
      isImageInfoValid="+p.isImageInfoValid()
               +"isTableInfoValid="+p.isTableInfoValid());
               else
               System.out.println("##### Params -> null");

                  }
               catch(Exception e)
               {
               e.printStackTrace();
               }
      }
      }


      May be related to issue #4094302
      (Review ID: 133251)
      ======================================================================

            campbell Christopher Campbell (Inactive)
            bstrathesunw Bill Strathearn (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: