[PATCH] Improve safety of FormatMessage() calls on Windows

Started by Christian Ullrichabout 10 years ago2 messageshackers
Jump to latest
#1Christian Ullrich
chris@chrullrich.net

There are some instances of calls to FormatMessage() with the
FORMAT_MESSAGE_FROM_SYSTEM flag that omit the
FORMAT_MESSAGE_IGNORE_INSERTS flag. The effect of that is that if the
requested message string contains any insertion markers, the call to
FormatMessage() will fail because none of these calls pass an argument list.

This patch adds the ...IGNORE_INSERTS flag to these calls.

The documentation for FormatMessage() does not clearly say that a NULL
argument list is not an implicit IGNORE_INSERTS flag, but Chen does at
<https://blogs.msdn.microsoft.com/oldnewthing/20071128-00/?p=24353&gt;.

--
Christian

Attachments:

formatmessage-inserts.patchtext/plain; charset=UTF-8; name=formatmessage-inserts.patchDownload+10-10
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Christian Ullrich (#1)
Re: [PATCH] Improve safety of FormatMessage() calls on Windows

Christian Ullrich <chris@chrullrich.net> writes:

There are some instances of calls to FormatMessage() with the
FORMAT_MESSAGE_FROM_SYSTEM flag that omit the
FORMAT_MESSAGE_IGNORE_INSERTS flag. The effect of that is that if the
requested message string contains any insertion markers, the call to
FormatMessage() will fail because none of these calls pass an argument list.

This patch adds the ...IGNORE_INSERTS flag to these calls.

Good catch, pushed (with some cosmetic reformatting).

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers