Two minor changes to the use of FormatMessageA in Win32ErrorLogMessage:
- Follow the MSDN advice and use FORMAT_MESSAGE_IGNORE_INSERTS to avoid security issues and to prevent getting back ERROR_INVALID_PARAMETER for any message that has inserts. This is always the right thing since this function provides no arguments for inserts.
- Don't specify a language identifier, thereby allowing FormatMessageA to make many sensible attempts to find a string in some suitable language.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/3888001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63166 0039d316-1c4b-4281-b951-d872f2087c98
CrOS-Libchrome-Original-Commit: 6ac3df5ed73f0ba6762df74f7ccf270f6db2ef2c
diff --git a/base/logging.cc b/base/logging.cc
index dfe9b0a..273162f 100644
--- a/base/logging.cc
+++ b/base/logging.cc
@@ -706,7 +706,7 @@
Win32ErrorLogMessage::~Win32ErrorLogMessage() {
const int error_message_buffer_size = 256;
char msgbuf[error_message_buffer_size];
- DWORD flags = FORMAT_MESSAGE_FROM_SYSTEM;
+ DWORD flags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS;
HMODULE hmod;
if (module_) {
hmod = GetModuleHandleA(module_);
@@ -725,7 +725,7 @@
DWORD len = FormatMessageA(flags,
hmod,
err_,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ 0,
msgbuf,
sizeof(msgbuf) / sizeof(msgbuf[0]),
NULL);