Thread (43 messages) flat view 43 messages, 5 authors, 2016-06-15

Re: [msysGit] [PATCH v3 02/14] mingw: implement syslog

From: Erik Faye-Lund <hidden>
Date: 2016-06-15 22:49:45

On Sun, Oct 10, 2010 at 10:51 PM, Johannes Sixt [off-list ref] wrote:
On Sonntag, 10. Oktober 2010, Erik Faye-Lund wrote:
quoted
On Sun, Oct 10, 2010 at 9:50 PM, Eric Sunshine [off-list ref]
wrote:
quoted
quoted
On 10/10/2010 9:20 AM, Erik Faye-Lund wrote:
quoted
+       /*
+        * ReportEvent() doesn't handle strings containing %n, where n
is +        * an integer. Such events must be reformatted by the caller.
+        */
The comment about '%n' seems to be warning about a potential problem but
does not actually protect against it. Should this issue be handled?
This is again an issue that was discussed in the first round.
ReportEvent() CANNOT report a string containing "%n" (where n is an
integer). And while we could probably try to work around it by
inserting a space or something, and I don't think we ever were able to
find a case where we could report a string containing "%n" in the
first place...
I recall that it was mentioned that this could happen for IPv6 addresses?
Ah, that's right. Microsoft even mentions it in MSDN: "Note that the
string that you log cannot contain %n, where n is an integer value
(for example, %1) because the event viewer treats it as an insertion
string. Because an IPv6 address can contain this character sequence,
you cannot log an event message that contains an IPv6 address".

What should we do about it? Error out?

Strangely enough, reporting strings with "%1" works fine when I test
it now. Perhaps this is dependent on the windows-version?

Yep, it is. On Vista 64 it seems to work, but on WinXP it does not.
The string gets expanded into itself 100 times, and then there's
apparently a recursion test.

Also, it is only %1 that does not report correctly on WinXP, probably
because of a check against the wNumStrings-parameter. Even strings
like %11 does not expand.

FormatMessage has the FORMAT_MESSAGE_IGNORE_INSERTS-flag to avoid this
kind of expansion, but unfortunately I can't find similar
functionality for ReportEvent :(
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help