Commit af5964de authored by Francois Doray's avatar Francois Doray Committed by Commit Bot

[breakpad] DCHECK that crash key size is below limit.

Currently, Breakpad will silently truncate a crash key name with a
length above the limit of 40 characters. Unfortunately, trying to
retrieve the value of the key with crash_reporter::GetCrashKeyValue()
will fail, as the truncated name is not used for retrieval.

This CL adds a DCHECK for the crash key length, to avoid having
other people chasing the same problem as me when writing a test
for crash keys.

Change-Id: I6f08ddcb5df9589b7604f34fbeb2dbb6573b1b20
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1999220
Commit-Queue: François Doray <fdoray@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732520}
parent 112d1736
......@@ -72,6 +72,7 @@ using CrashKeyString = crashpad::StringAnnotation<MaxLength>;
namespace internal {
constexpr size_t kCrashKeyStorageKeySize = 40;
constexpr size_t kCrashKeyStorageNumEntries = 200;
constexpr size_t kCrashKeyStorageValueSize = 128;
......
......@@ -50,6 +50,10 @@ void ResetCrashKeyStorageForTesting() {
}
void CrashKeyStringImpl::Set(base::StringPiece value) {
// This check cannot be in the constructor because it is constexpr. Use _LT
// rather than _LE to account for the terminating \0.
DCHECK_LT(strlen(name_), kCrashKeyStorageKeySize);
const size_t kValueMaxLength = index_array_count_ * kCrashKeyStorageValueSize;
TransitionalCrashKeyStorage* storage = GetCrashKeyStorage();
......
......@@ -12,8 +12,10 @@
namespace crash_reporter {
namespace internal {
using TransitionalCrashKeyStorage = google_breakpad::
NonAllocatingMap<40, kCrashKeyStorageValueSize, kCrashKeyStorageNumEntries>;
using TransitionalCrashKeyStorage =
google_breakpad::NonAllocatingMap<kCrashKeyStorageKeySize,
kCrashKeyStorageValueSize,
kCrashKeyStorageNumEntries>;
// Accesses the underlying storage for crash keys for non-Crashpad clients.
CRASH_KEY_EXPORT TransitionalCrashKeyStorage* GetCrashKeyStorage();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment