Skip to content

Commit

Permalink
Fix for LOG4NET-67. CVE-2006-0743 Security vulnerability in LocalSysl…
Browse files Browse the repository at this point in the history
…ogAppender
  • Loading branch information
Nicko Cadell committed Mar 7, 2006
1 parent fc9e55d commit ea3faab
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/Appender/LocalSyslogAppender.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#region Copyright & License
/*
* Copyright 2004-2005 The Apache Software Foundation
* Copyright 2004-2006 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -379,7 +379,9 @@ protected override void Append(LoggingEvent loggingEvent)
int priority = GeneratePriority(m_facility, GetSeverity(loggingEvent.Level));
string message = RenderLoggingEvent(loggingEvent);

syslog(priority, message);
// Call the local libc syslog method
// The second argument is a printf style format string
syslog(priority, "%s", message);
}

/// <summary>
Expand Down Expand Up @@ -533,8 +535,17 @@ private static int GeneratePriority(SyslogFacility facility, SyslogSeverity seve
/// <summary>
/// Generate a log message.
/// </summary>
[DllImport("libc")]
private static extern void syslog(int priority, string message);
/// <remarks>
/// <para>
/// The libc syslog method takes a format string and a variable argument list similar
/// to the classic printf function. As this type of vararg list is not supported
/// by C# we need to specify the arguments explicitly. Here we have specified the
/// format string with a single message argument. The caller must set the format
/// string to <c>"%s"</c>.
/// </para>
/// </remarks>
[DllImport("libc", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl)]
private static extern void syslog(int priority, string format, string message);

/// <summary>
/// Close descriptor used to write to system logger.
Expand Down

0 comments on commit ea3faab

Please sign in to comment.