Issue Details (XML | Word | Printable)

Key: LOG4NET-69
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Critical Critical
Assignee: Nicko Cadell
Reporter: Ron Grabowski
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Log4net

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

Created: 17/Mar/06 01:07 PM   Updated: 28/Mar/06 08:22 AM
Return to search
Component/s: None
Affects Version/s: 1.2.9
Fix Version/s: 1.2.10

Time Tracking:
Not Specified

Resolution Date: 28/Mar/06 08:22 AM


 Description  « Hide
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.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Ron Grabowski made changes - 17/Mar/06 01:08 PM
Field Original Value New Value
Description This statement:

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

throw 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.
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.
Repository Revision Date User Message
ASF #386707 Fri Mar 17 20:26:53 UTC 2006 nicko Fix for LOG4NET-69.
Added new wrapped implementation of String.Format in Transform.StringFormat. This method will not throw exceptions. Added some more exception handling code to the Logger.
Files Changed
MODIFY /logging/log4net/trunk/log4net.build
MODIFY /logging/log4net/trunk/src/Core/LogImpl.cs
MODIFY /logging/log4net/trunk/src/Repository/Hierarchy/Logger.cs
MODIFY /logging/log4net/trunk/src/Util/Transform.cs
MODIFY /logging/log4net/trunk/extensions/net/1.0/log4net.Ext.Trace/cs/src/TraceLogImpl.cs
MODIFY /logging/log4net/trunk/src/Core/ILogger.cs

Nicko Cadell made changes - 18/Mar/06 04:06 AM
Assignee Nicko Cadell [ nicko ]
Nicko Cadell added a comment - 18/Mar/06 04:08 AM
Reduced length of summary as it formats better in the release notes

Nicko Cadell made changes - 18/Mar/06 04:08 AM
Description 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.
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.
Summary FormatException thrown when *Format methods are given a malformed format string: log.DebugFormat("Malformed {{,,,5}format{8}!"); Exception thrown when *Format methods are given a malformed format string
Nicko Cadell added a comment - 18/Mar/06 04:09 AM
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.

Nicko Cadell made changes - 18/Mar/06 04:09 AM
Affects Version/s 1.2.10 [ 11128 ]
Affects Version/s v.Next [ 12310261 ]
Nicko Cadell added a comment - 28/Mar/06 08:22 AM
This is fixed and i have added a test to ensure that malformed format strings don't leak exceptions.

Nicko Cadell made changes - 28/Mar/06 08:22 AM
Resolution Fixed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
Fix Version/s 1.2.10 [ 11128 ]