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

CONSTANT_NameAndType_info permits references to illegal names and descriptors

XMLWordPrintable

    • b137
    • Not verified

      According to
      https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.6

      there is several requirements to name_index and descriptor_index references.
      1. name_index should point to valid field or method name. So, names which contains no characters or contains any of (.;/[) should be prohibited.

      Actual behaviour:
      names 'm[', 'm.', 'm/', m;', '', '/' are permitted (see tests at vm/classfmt/cpl/cplnat005/cplnat00501m_invalidname_v*)

      These names are prohibited in the case given NameAndType is referenced from fieldref, Methodref or InterfaceMethodref.

      2. descriptor_index should be valid method or field descriptor.
      Actual behaviour: descriptors containing classes with invalid binary names aren't prohibited. E.g. following descriptors are possible:
      Lt//T;
      Lt///T;
      Lt/T.;
      Lt/T[;
      Lt/T;;
      Lt/T.;
      Lt;/T;
      (Lt//T;)V
      (Lt/T[;)V
      ... etc, see more at vm/classfmt/cpl/cplnat006/cplnat00601m_method_invaliddesc_v* and vm/classfmt/cpl/cplnat006/cplnat00601m_field_invaliddesc_v* correspondingly.

      However some of bad methods signatures are prohibited (for version 53):
      (Lt/T;;)V
      (Lt;/T;)V
      ()Lt/T.;
      ()Lt/T;;
      ()Lt;/T;
      (Lt/T.;)V

      The behavour of 'unused' NameAndType structure and structure referenced by Fieldref/Methodref/InterfaceMethodref (unused) are the same.


      Was found on jdk9b123. Tests already in repository. Separate examples will be attached by request.

        There are no Sub-Tasks for this issue.

            rprotacio Rachel Protacio (Inactive)
            asolodkaya Anastasiya Solodkaya (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: