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

JarFile.getManifest() should handle manifest attribute name 70 bytes

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 1.0, 5.0
    • Fix Version/s: 11
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b04
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Description

      The following code, JarFile.getManifest(), throw IOException: invalid header field
      when the manifest contains header name with 70 bytes.

      JAR Manifest specification state:"
       Because header names cannot be continued, the maximum length of a header name is 70 bytes (there must be a colon and a SPACE after the name)."
      getManifest() should not throw IOException at 70 bytes header name (current, it handle up to 69 bytes.)

      import java.io.*;
      import java.util.*;
      import java.util.jar.*;
          
      public class ManifestTest {
        public static void main(String args[])
        {
          if (args.length != 1) {
            System.err.println("usage: manif file.jar");
            System.exit(1);
          }
          
          try {
            JarFile jf = new JarFile(args[0]);
            Manifest manif = jf.getManifest();
            /*
            if (manif != null) {
              manif.write(System.out);
              Attributes attr =
                manif.getMainAttributes();
              String attrname =
                "Specification-Version";
              String str =
                attr.getValue(attrname);
              System.out.println(str);
            }
            */
          }
          catch (IOException e) {
            System.err.println(e);
          }
        }
      }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                rriggs Roger Riggs
                Reporter:
                duke J. Duke (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: