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

Side by Side Diff: chrome/app/breakpad_win.cc

Issue 14262014: Fix some bugs in the handling of dynamic crash keys. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initial CL Created 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/app/breakpad_win.h" 5 #include "chrome/app/breakpad_win.h"
6 6
7 #include <shellapi.h> 7 #include <shellapi.h>
8 #include <tchar.h> 8 #include <tchar.h>
9 #include <userenv.h> 9 #include <userenv.h>
10 #include <windows.h> 10 #include <windows.h>
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 } 752 }
753 } 753 }
754 754
755 extern "C" void __declspec(dllexport) __cdecl SetNumberOfViews( 755 extern "C" void __declspec(dllexport) __cdecl SetNumberOfViews(
756 int number_of_views) { 756 int number_of_views) {
757 SetIntegerValue(g_num_of_views_offset, number_of_views); 757 SetIntegerValue(g_num_of_views_offset, number_of_views);
758 } 758 }
759 759
760 void SetCrashKeyValue(const base::StringPiece& key, 760 void SetCrashKeyValue(const base::StringPiece& key,
761 const base::StringPiece& value) { 761 const base::StringPiece& value) {
762 std::string key_string = key.as_string(); 762 // CustomInfoEntry limits the length of key and value. If they exceed
763 // their maximum length the underlying string handling functions raise
764 // an exception and prematurely trigger a crash. Truncate here.
765 base::StringPiece safe_key(key.substr(
766 0, google_breakpad::CustomInfoEntry::kNameMaxLength - 1));
767 base::StringPiece safe_value(value.substr(
768 0, google_breakpad::CustomInfoEntry::kValueMaxLength - 1));
Robert Sesek 2013/04/16 17:54:29 The crash_logging system should be doing this trun
Roger McFarlane (Chromium) 2013/04/16 18:18:23 What I've observed is that if you get down to entr
763 769
770 // Keep a copy of the safe key as a std::string, we'll reuse it later.
771 std::string key_string(safe_key.begin(), safe_key.end());
772
773 // If we already have a value for this key, update it; otherwise, insert
774 // the new value if we have not exhausted the pre-allocated slots for dynamic
775 // entries.
764 DynamicEntriesMap::iterator it = g_dynamic_entries->find(key_string); 776 DynamicEntriesMap::iterator it = g_dynamic_entries->find(key_string);
765 google_breakpad::CustomInfoEntry* entry = NULL; 777 google_breakpad::CustomInfoEntry* entry = NULL;
766 if (it == g_dynamic_entries->end()) { 778 if (it == g_dynamic_entries->end()) {
767 if (g_dynamic_keys_offset >= g_dynamic_entries_count) 779 if (g_dynamic_entries->size() >= g_dynamic_entries_count)
768 return; 780 return;
769 entry = &(*g_custom_entries)[g_dynamic_keys_offset++]; 781 entry = &(*g_custom_entries)[g_dynamic_keys_offset++];
770 g_dynamic_entries->insert(std::make_pair(key_string, entry)); 782 g_dynamic_entries->insert(std::make_pair(key_string, entry));
771 } else { 783 } else {
772 entry = it->second; 784 entry = it->second;
773 } 785 }
774 786
775 entry->set(UTF8ToWide(key).data(), UTF8ToWide(value).data()); 787 entry->set(UTF8ToWide(safe_key).data(), UTF8ToWide(safe_value).data());
776 } 788 }
777 789
778 extern "C" void __declspec(dllexport) __cdecl SetCrashKeyValuePair( 790 extern "C" void __declspec(dllexport) __cdecl SetCrashKeyValuePair(
779 const char* key, const char* value) { 791 const char* key, const char* value) {
780 SetCrashKeyValue(base::StringPiece(key), base::StringPiece(value)); 792 SetCrashKeyValue(base::StringPiece(key), base::StringPiece(value));
781 } 793 }
782 794
783 void ClearCrashKeyValue(const base::StringPiece& key) { 795 void ClearCrashKeyValue(const base::StringPiece& key) {
784 DynamicEntriesMap::iterator it = g_dynamic_entries->find(key.as_string()); 796 DynamicEntriesMap::iterator it = g_dynamic_entries->find(key.as_string());
785 if (it == g_dynamic_entries->end()) 797 if (it == g_dynamic_entries->end())
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 previous_filter = SetUnhandledExceptionFilter(filter); 1142 previous_filter = SetUnhandledExceptionFilter(filter);
1131 } 1143 }
1132 1144
1133 void StringVectorToCStringVector(const std::vector<std::wstring>& wstrings, 1145 void StringVectorToCStringVector(const std::vector<std::wstring>& wstrings,
1134 std::vector<const wchar_t*>* cstrings) { 1146 std::vector<const wchar_t*>* cstrings) {
1135 cstrings->clear(); 1147 cstrings->clear();
1136 cstrings->reserve(wstrings.size()); 1148 cstrings->reserve(wstrings.size());
1137 for (size_t i = 0; i < wstrings.size(); ++i) 1149 for (size_t i = 0; i < wstrings.size(); ++i)
1138 cstrings->push_back(wstrings[i].c_str()); 1150 cstrings->push_back(wstrings[i].c_str());
1139 } 1151 }
OLDNEW
« 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