| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/process_singleton.h" | 5 #include "chrome/browser/process_singleton.h" |
| 6 | 6 |
| 7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
| 10 #include "base/win_util.h" | 10 #include "base/win_util.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 LOG(WARNING) << "Not handling WM_COPYDATA as browser is shutting down"; | 162 LOG(WARNING) << "Not handling WM_COPYDATA as browser is shutting down"; |
| 163 return FALSE; | 163 return FALSE; |
| 164 } | 164 } |
| 165 | 165 |
| 166 // If locked, it means we are not ready to process this message because | 166 // If locked, it means we are not ready to process this message because |
| 167 // we are probably in a first run critical phase. | 167 // we are probably in a first run critical phase. |
| 168 if (locked_) | 168 if (locked_) |
| 169 return TRUE; | 169 return TRUE; |
| 170 | 170 |
| 171 // We should have enough room for the shortest command (min_message_size) | 171 // We should have enough room for the shortest command (min_message_size) |
| 172 // and also be a multiple of wchar_t bytes. | 172 // and also be a multiple of wchar_t bytes. The shortest command |
| 173 // possible is L"START\0\0" (empty current directory and command line). |
| 173 static const int min_message_size = 7; | 174 static const int min_message_size = 7; |
| 174 if (cds->cbData < min_message_size || cds->cbData % sizeof(wchar_t) != 0) { | 175 if (cds->cbData < min_message_size * sizeof(wchar_t) || |
| 176 cds->cbData % sizeof(wchar_t) != 0) { |
| 175 LOG(WARNING) << "Invalid WM_COPYDATA, length = " << cds->cbData; | 177 LOG(WARNING) << "Invalid WM_COPYDATA, length = " << cds->cbData; |
| 176 return TRUE; | 178 return TRUE; |
| 177 } | 179 } |
| 178 | 180 |
| 179 // We split the string into 4 parts on NULLs. | 181 // We split the string into 4 parts on NULLs. |
| 182 DCHECK(cds->lpData); |
| 180 const std::wstring msg(static_cast<wchar_t*>(cds->lpData), | 183 const std::wstring msg(static_cast<wchar_t*>(cds->lpData), |
| 181 cds->cbData / sizeof(wchar_t)); | 184 cds->cbData / sizeof(wchar_t)); |
| 182 const std::wstring::size_type first_null = msg.find_first_of(L'\0'); | 185 const std::wstring::size_type first_null = msg.find_first_of(L'\0'); |
| 183 if (first_null == 0 || first_null == std::wstring::npos) { | 186 if (first_null == 0 || first_null == std::wstring::npos) { |
| 184 // no NULL byte, don't know what to do | 187 // no NULL byte, don't know what to do |
| 185 LOG(WARNING) << "Invalid WM_COPYDATA, length = " << msg.length() << | 188 LOG(WARNING) << "Invalid WM_COPYDATA, length = " << msg.length() << |
| 186 ", first null = " << first_null; | 189 ", first null = " << first_null; |
| 187 return TRUE; | 190 return TRUE; |
| 188 } | 191 } |
| 189 | 192 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 switch (message) { | 250 switch (message) { |
| 248 case WM_COPYDATA: | 251 case WM_COPYDATA: |
| 249 return OnCopyData(reinterpret_cast<HWND>(wparam), | 252 return OnCopyData(reinterpret_cast<HWND>(wparam), |
| 250 reinterpret_cast<COPYDATASTRUCT*>(lparam)); | 253 reinterpret_cast<COPYDATASTRUCT*>(lparam)); |
| 251 default: | 254 default: |
| 252 break; | 255 break; |
| 253 } | 256 } |
| 254 | 257 |
| 255 return ::DefWindowProc(hwnd, message, wparam, lparam); | 258 return ::DefWindowProc(hwnd, message, wparam, lparam); |
| 256 } | 259 } |
| OLD | NEW |