Log4j 2
  1. Log4j 2
  2. LOG4J2-114

StructuredDataMessage is incorrectly validating value length instead of key length

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-beta2
    • Fix Version/s: 2.0-beta4
    • Component/s: API
    • Labels:
      None

      Description

      During execution of method SLF4JLogger.log, the following exception is thrown during creation of the StructuredMessage with a key longer than 32 characters.

      java.lang.IllegalArgumentException: Structured data values are limited to 32 characters. key: memo value: This is a very long test memo to demonstrate the issue

      The validation should be on key length and not the value length.

        Activity

        Hide
        Arkin Yetis added a comment - - edited

        Attached proposed fix and related test updates.

        Show
        Arkin Yetis added a comment - - edited Attached proposed fix and related test updates.
        Hide
        Gary Gregory added a comment -

        The only length 32 restriction I see in https://tools.ietf.org/html/rfc5424 is "The "swVersion" parameter is a string. It MUST NOT be longer than 32 characters." What am I missing?

        Show
        Gary Gregory added a comment - The only length 32 restriction I see in https://tools.ietf.org/html/rfc5424 is "The "swVersion" parameter is a string. It MUST NOT be longer than 32 characters." What am I missing?
        Hide
        Ralph Goers added a comment -

        Take a look at section 6.

        PARAM_NAME is of type SD_NAME which is 1*32PRINTUSASCII (1-32 US ASCII printable characters). Right now we are only validating the length, not the characters.

        Also note that HOSTNAME, APP-NAME, PROCID and MSGID also have length restrictions. However PARAM_VALUE does not.

        Show
        Ralph Goers added a comment - Take a look at section 6. PARAM_NAME is of type SD_NAME which is 1*32PRINTUSASCII (1-32 US ASCII printable characters). Right now we are only validating the length, not the characters. Also note that HOSTNAME, APP-NAME, PROCID and MSGID also have length restrictions. However PARAM_VALUE does not.
        Hide
        Ralph Goers added a comment - - edited

        The patch was applied although the test had to be modified slightly as it didn't incorporate the new memo item that was added. Please verify and close.

        Show
        Ralph Goers added a comment - - edited The patch was applied although the test had to be modified slightly as it didn't incorporate the new memo item that was added. Please verify and close.

          People

          • Assignee:
            Ralph Goers
            Reporter:
            Arkin Yetis
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development