Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-2001

StyleConverter.newInstance argument validation is incorrect

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.8.2
    • Fix Version/s: 2.9.0
    • Component/s: Configurators
    • Labels:
      None

      Description

      There are three bugs in the argument handling of StyleConverter.newInstance.
      Firstly the javadoc says options may be null. It must not be.
      Secondly the method doesn't validate that it is not null.
      Thirdly it validates that options.length <1 when the subsequent code requires options.length >=2

          /**
           * Gets an instance of the class.
           *
           * @param config
           *            The current Configuration.
           * @param options
           *            pattern options, may be null. If first element is "short", only the first line of the throwable will
           *            be formatted.
           * @return instance of class.
           */
          public static StyleConverter newInstance(final Configuration config, final String[] options) {
              if (options.length < 1) {
                  LOGGER.error("Incorrect number of options on style. Expected at least 1, received " + options.length);
                  return null;
              }
              if (options[0] == null) {
                  LOGGER.error("No pattern supplied on style");
                  return null;
              }
              if (options[1] == null) {
                  LOGGER.error("No style attributes provided");
                  return null;
              }
      

        Activity

        Hide
        garydgregory Gary Gregory added a comment -

        Thank you for your report.

        Please feel free to provide a patch on GitHub https://github.com/apache/logging-log4j2

        Gary

        Show
        garydgregory Gary Gregory added a comment - Thank you for your report. Please feel free to provide a patch on GitHub https://github.com/apache/logging-log4j2 Gary
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 80a496327fc0ae7b33308b114d034ff91699f595 in logging-log4j2's branch refs/heads/master from Gary Gregory
        [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=80a4963 ]

        LOG4J2-2001 StyleConverter.newInstance argument validation is
        incorrect.

        Show
        jira-bot ASF subversion and git services added a comment - Commit 80a496327fc0ae7b33308b114d034ff91699f595 in logging-log4j2's branch refs/heads/master from Gary Gregory [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=80a4963 ] LOG4J2-2001 StyleConverter.newInstance argument validation is incorrect.
        Hide
        garydgregory Gary Gregory added a comment -

        In Git master. Please verify and close this issue.

        Show
        garydgregory Gary Gregory added a comment - In Git master. Please verify and close this issue.

          People

          • Assignee:
            garydgregory Gary Gregory
            Reporter:
            pburrowesOC Paul Burrowes
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development