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

CodeSource.getCodeSigners() throws NPE within empty certs

XMLWordPrintable

    • Fix Understood
    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      The test case triggers a NullPointerException in CodeSource.getCodeSigners() when a CodeSource instance is constructed with an empty certificate array (new java.security.cert.Certificate[0]). The signers field remains null after the constructor finishes, yet the getCodeSigners() method attempts to call signers.clone() without checking for null, resulting in the NPE.


      ---------- BEGIN SOURCE ----------
      import java.io.File;
      import java.net.URL;
      import java.security.CodeSource;

      public class CertsMatch {

          public static void main(String[] args) throws Exception {
              File certsFile = new File(System.getProperty("test.src", "."), "certs");
              URL location = certsFile.toURI().toURL();
              
              CodeSource csEmptyCerts = new CodeSource(location, new java.security.cert.Certificate[0]);

              csEmptyCerts.getCodeSigners();
          }
      }
      ---------- END SOURCE ----------

            serb Sergey Bylokhov
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: