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

Side by Side Diff: sync/internal_api/syncapi_internal.cc

Issue 1161463005: [Sync] Don't crash for encryption errors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comments Created 5 years, 6 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
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 "sync/internal_api/syncapi_internal.h" 5 #include "sync/internal_api/syncapi_internal.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "sync/protocol/attachments.pb.h" 8 #include "sync/protocol/attachments.pb.h"
9 #include "sync/protocol/password_specifics.pb.h" 9 #include "sync/protocol/password_specifics.pb.h"
10 #include "sync/protocol/sync.pb.h" 10 #include "sync/protocol/sync.pb.h"
(...skipping 12 matching lines...) Expand all
23 sync_pb::PasswordSpecificsData* DecryptPasswordSpecifics( 23 sync_pb::PasswordSpecificsData* DecryptPasswordSpecifics(
24 const sync_pb::EntitySpecifics& specifics, Cryptographer* crypto) { 24 const sync_pb::EntitySpecifics& specifics, Cryptographer* crypto) {
25 if (!specifics.has_password()) 25 if (!specifics.has_password())
26 return NULL; 26 return NULL;
27 const sync_pb::PasswordSpecifics& password_specifics = specifics.password(); 27 const sync_pb::PasswordSpecifics& password_specifics = specifics.password();
28 if (!password_specifics.has_encrypted()) 28 if (!password_specifics.has_encrypted())
29 return NULL; 29 return NULL;
30 const sync_pb::EncryptedData& encrypted = password_specifics.encrypted(); 30 const sync_pb::EncryptedData& encrypted = password_specifics.encrypted();
31 scoped_ptr<sync_pb::PasswordSpecificsData> data( 31 scoped_ptr<sync_pb::PasswordSpecificsData> data(
32 new sync_pb::PasswordSpecificsData); 32 new sync_pb::PasswordSpecificsData);
33 if (!crypto->CanDecrypt(encrypted))
34 return NULL;
33 if (!crypto->Decrypt(encrypted, data.get())) 35 if (!crypto->Decrypt(encrypted, data.get()))
34 return NULL; 36 return NULL;
35 return data.release(); 37 return data.release();
36 } 38 }
37 39
38 // The list of names which are reserved for use by the server. 40 // The list of names which are reserved for use by the server.
39 static const char* kForbiddenServerNames[] = { "", ".", ".." }; 41 static const char* kForbiddenServerNames[] = { "", ".", ".." };
40 42
41 // When taking a name from the syncapi, append a space if it matches the 43 // When taking a name from the syncapi, append a space if it matches the
42 // pattern of a server-illegal name followed by zero or more spaces. 44 // pattern of a server-illegal name followed by zero or more spaces.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 109
108 bool AreAttachmentMetadataEqual(const sync_pb::AttachmentMetadata& left, 110 bool AreAttachmentMetadataEqual(const sync_pb::AttachmentMetadata& left,
109 const sync_pb::AttachmentMetadata& right) { 111 const sync_pb::AttachmentMetadata& right) {
110 if (left.SerializeAsString() == right.SerializeAsString()) { 112 if (left.SerializeAsString() == right.SerializeAsString()) {
111 return true; 113 return true;
112 } 114 }
113 return false; 115 return false;
114 } 116 }
115 117
116 } // namespace syncer 118 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698