diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-24 22:02:23 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-24 22:02:23 +0000 |
commit | 366ffe559b8d2a422792394114d8cdb2746e8ad5 (patch) | |
tree | 4bc1df11f43b58e164c3c9f7ca8a3d59e5233dea | |
parent | c2732efe31f3ed2cefd9ef8ab35c71aed97d0a98 (diff) | |
download | chromium_src-366ffe559b8d2a422792394114d8cdb2746e8ad5.zip chromium_src-366ffe559b8d2a422792394114d8cdb2746e8ad5.tar.gz chromium_src-366ffe559b8d2a422792394114d8cdb2746e8ad5.tar.bz2 |
Fix for minimum size check
cds->cbData is data length in bytes, and min_message_size is in characters. So it needs to be multiplied by sizeof(wchar_t)
Review URL: http://codereview.chromium.org/93078
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14482 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | chrome/browser/process_singleton_win.cc | 7 |
2 files changed, 6 insertions, 2 deletions
@@ -33,3 +33,4 @@ Kim Christensen <kimworking@gmail.com> Paul Robinson <paulrobinson85@googlemail.com> Josué Ratelle <jorat1346@gmail.com> Edward Crossman <tedoc2000@gmail.com> +Nikita Ofitserov <himikof@gmail.com> diff --git a/chrome/browser/process_singleton_win.cc b/chrome/browser/process_singleton_win.cc index 289e4d1..99d2d5f 100644 --- a/chrome/browser/process_singleton_win.cc +++ b/chrome/browser/process_singleton_win.cc @@ -169,14 +169,17 @@ LRESULT ProcessSingleton::OnCopyData(HWND hwnd, const COPYDATASTRUCT* cds) { return TRUE; // We should have enough room for the shortest command (min_message_size) - // and also be a multiple of wchar_t bytes. + // and also be a multiple of wchar_t bytes. The shortest command + // possible is L"START\0\0" (empty current directory and command line). static const int min_message_size = 7; - if (cds->cbData < min_message_size || cds->cbData % sizeof(wchar_t) != 0) { + if (cds->cbData < min_message_size * sizeof(wchar_t) || + cds->cbData % sizeof(wchar_t) != 0) { LOG(WARNING) << "Invalid WM_COPYDATA, length = " << cds->cbData; return TRUE; } // We split the string into 4 parts on NULLs. + DCHECK(cds->lpData); const std::wstring msg(static_cast<wchar_t*>(cds->lpData), cds->cbData / sizeof(wchar_t)); const std::wstring::size_type first_null = msg.find_first_of(L'\0'); |