Uploaded image for project: 'Log4net'
  1. Log4net
  2. LOG4NET-69

Exception thrown when *Format methods are given a malformed format string

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 1.2.9
    • Fix Version/s: 1.2.10
    • Component/s: None
    • Labels:
      None

      Description

      FormatException thrown when *Format methods are given a malformed format string: log.DebugFormat("Malformed {{,,,5}format

      {8}!");

      This statement:

      log.DebugFormat("Malformed {{,,,5}format{8}

      !");

      throws the following exception:

      [FormatException: Input string was not in a correct format.]
      System.Text.StringBuilder.FormatError()
      System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String format, Object[] args)
      System.String.Format(IFormatProvider provider, String format, Object[] args)
      log4net.Core.LogImpl.DebugFormat(String format, Object[] args)

      which is consistent with the documentation for String.Format:

      System.FormatException: The format item in format is invalid. or The number indicating an argument to format is less than zero, or greater than or equal to the number of specified objects to format.

        Activity

        Hide
        nicko Nicko Cadell added a comment -

        Reduced length of summary as it formats better in the release notes

        Show
        nicko Nicko Cadell added a comment - Reduced length of summary as it formats better in the release notes
        Hide
        nicko Nicko Cadell added a comment -

        version 1.2.10 does not actualy exist yet so this issue does not affect it. The issue exists in the latest source code at present but should hopefully be fixed shortly.

        Show
        nicko Nicko Cadell added a comment - version 1.2.10 does not actualy exist yet so this issue does not affect it. The issue exists in the latest source code at present but should hopefully be fixed shortly.
        Hide
        nicko Nicko Cadell added a comment -

        This is fixed and i have added a test to ensure that malformed format strings don't leak exceptions.

        Show
        nicko Nicko Cadell added a comment - This is fixed and i have added a test to ensure that malformed format strings don't leak exceptions.
        Hide
        tartanbono Colin Santry added a comment -

        Hi,

        If getting the same issue, I'm using v1.2.10! I have just downloaded the 1.2.10 version today (23-Sep-2011).

        <log4net.Error>Exception during StringFormat: Input string was not in a correct format. <format>Reading config! User:

        {0} Domain:(1}</format><args>{test1, test2}</args></log4net.Error>

        Source line:
        log.DebugFormat("Reading config!\nUser:{0}

        \nDomain:(2}", "test1", "test2");

        Is 1.2.10 the latest? according to SourceForge the latest is v1.2.0-beta8 ?!

        Regards,
        Colin

        Show
        tartanbono Colin Santry added a comment - Hi, If getting the same issue, I'm using v1.2.10! I have just downloaded the 1.2.10 version today (23-Sep-2011). <log4net.Error>Exception during StringFormat: Input string was not in a correct format. <format>Reading config! User: {0} Domain:(1}</format><args>{test1, test2}</args></log4net.Error> Source line: log.DebugFormat("Reading config!\nUser:{0} \nDomain:(2}", "test1", "test2"); Is 1.2.10 the latest? according to SourceForge the latest is v1.2.0-beta8 ?! Regards, Colin
        Hide
        bodewig Stefan Bodewig added a comment -

        Collin, are you getting an exception or a error message? The error message is expected while an exception would be what the bug report is about.

        Yes, 1.2.10 is the latest as of now, the sourceforge page is old, log4net is an Apache project by now.

        The message you cite "User:

        {0} Domain:(1}" doesn't match the code you cite: "User:{0}

        \nDomain:(2}" - in one of the two a Copy/Paste error?

        Show
        bodewig Stefan Bodewig added a comment - Collin, are you getting an exception or a error message? The error message is expected while an exception would be what the bug report is about. Yes, 1.2.10 is the latest as of now, the sourceforge page is old, log4net is an Apache project by now. The message you cite "User: {0} Domain:(1}" doesn't match the code you cite: "User:{0} \nDomain:(2}" - in one of the two a Copy/Paste error?
        Hide
        tartanbono Colin Santry added a comment -

        Sorry Stefan,

        I've just sorted it, just came on to write comment to ignore entry... but you beat me to it!

        Sorry again for wasting your time... was indeed an error...

        Regards,
        Colin

        Show
        tartanbono Colin Santry added a comment - Sorry Stefan, I've just sorted it, just came on to write comment to ignore entry... but you beat me to it! Sorry again for wasting your time... was indeed an error... Regards, Colin

          People

          • Assignee:
            nicko Nicko Cadell
            Reporter:
            ron Ron Grabowski
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development