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

Incorrect Manifest file parsing in JDK

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 6u2
    • core-libs

      OPERATING SYSTEM(S):
      Windows XP

      FULL JDK VERSION(S):
      java version "1.6.0_01"
      Java(TM) SE Runtime Environment (build 1.6.0_01-b04)
      Java HotSpot(TM) Client VM (build 1.6.0_01-b04, mixed mode)

      DESCRIPTION:

      On executing the below Test case (ManifestTest.java) using the manifest file MANIFEST.MF we could see the following output

      [Eclipse-AutoStart, Manifest-Version, Bundle-Localization, Bundle-Name, Copyright, Require-Bundle, DynamicImport-Package, Bundle-Vendor, Bundle-Version, SCCSID, Bundle-Activator, Bundle-ManifestVersion, J2EE-DeploymentFactory-Implementation-Class, Import-Package, Bundle-SymbolicName, Eclipse-RegisterBuddy]

      The issue found here is that the "Export-Package" attribute, which is present in the manifest file, does not appear in the above list.


      Testcase:
      ---------

      import java.io.*;
      import java.util.jar.*;
      public class ManifestTest {
          public static void main(String args[])
          {
              try {
                  FileInputStream fis = new FileInputStream(args[0]);
                  Manifest mf = new Manifest(fis);
                  System.out.println(mf.getMainAttributes().keySet());
              } catch (Exception e) {
              }
          }
      }

      Steps to reproduce:

      Compile and run ManifestTest.java:

        java ManifestTest [manifest file]

      The manifest file we used to reproduce the problem can be downloaded from here:

        ftp://ftp.emea.ibm.com/fromibm/other/MANIFEST.MF


      Analysis:

      In Attributes.java ,there is function called

        read(Manifest.FastInputStream is, byte[] lbuf)

      which parses the attribute-value pair and puts in the table.The issue is when it continues to parse and reaches the last line of the last attribute.It collects the last line but it happens to go into the condition

        if (is.peek() == ' ') {}

      and then continue with the loop. As there are no more lines to read, it exits the loop, and the last attribute is not captured.

      So the fix could be like

        if (is.peek() == ' ' && is.available()!=0) {}

      which would check for the availability and based on that it may enter the "if" or not.

            bristor Dave Bristor (Inactive)
            elarsen Erik Larsen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: