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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 11
    • 1.0, 5.0
    • core-libs
    • b04
    • generic
    • generic
    • Verified

      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);
          }
        }
      }

            rriggs Roger Riggs
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: