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

Unified Diff: client/settings.cc

Issue 1007433003: Add a magic number to settings.dat for better identification (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 9 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: client/settings.cc
diff --git a/client/settings.cc b/client/settings.cc
index b4e5f434b44e12a60e85a46665c585d0774d7df9..aa2c4f8f21ac9d52ab5c78de9fb6467a9e97d174 100644
--- a/client/settings.cc
+++ b/client/settings.cc
@@ -28,19 +28,24 @@
namespace crashpad {
struct ALIGNAS(4) Settings::Data {
- static const uint16_t kSettingsVersion = 1;
+ static const uint32_t kSettingsMagic = 'CPds';
+ static const uint32_t kSettingsVersion = 1;
enum Options : uint32_t {
kUploadsEnabled = 1 << 0,
};
- Data() : version(kSettingsVersion),
+ Data() : magic(kSettingsMagic),
+ version(kSettingsVersion),
options(0),
+ padding_0(0),
last_upload_attempt_time(0),
client_id() {}
+ uint32_t magic;
uint32_t version;
uint32_t options;
+ uint32_t padding_0;
uint64_t last_upload_attempt_time; // time_t
UUID client_id;
};
@@ -193,6 +198,11 @@ bool Settings::ReadSettings(FileHandle handle, Data* out_data) {
if (!LoggingReadFile(handle, out_data, sizeof(*out_data)))
return false;
+ if (out_data->magic != Data::kSettingsMagic) {
+ LOG(ERROR) << "Settings magic is not " << Data::kSettingsMagic;
+ return false;
+ }
+
Robert Sesek 2015/03/12 23:26:48 Should we also ensure the padding is 0?
if (out_data->version != Data::kSettingsVersion) {
LOG(ERROR) << "Settings version is not " << Data::kSettingsVersion;
return false;
« 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