Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2925)

Unified Diff: chrome/browser/process_singleton_win.cc

Issue 93078: Fix for minimum size check (Closed)
Patch Set: Added DCHECK Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/process_singleton_win.cc
diff --git a/chrome/browser/process_singleton_win.cc b/chrome/browser/process_singleton_win.cc
index 289e4d19e44cc02e5dd630f23913fa2b3cfda76b..99d2d5fa75e45d0f132ac4353371d1ef3c4b7fd7 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');
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698