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

Side by Side Diff: chrome/common/visitedlink_common.cc

Issue 7068017: Fix bug in history salt computation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/visitedlink/visitedlink_master.cc ('k') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/common/visitedlink_common.h" 5 #include "chrome/common/visitedlink_common.h"
6 6
7 #include <string.h> // for memset() 7 #include <string.h> // for memset()
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/md5.h" 10 #include "base/md5.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 // static 75 // static
76 VisitedLinkCommon::Fingerprint VisitedLinkCommon::ComputeURLFingerprint( 76 VisitedLinkCommon::Fingerprint VisitedLinkCommon::ComputeURLFingerprint(
77 const char* canonical_url, 77 const char* canonical_url,
78 size_t url_len, 78 size_t url_len,
79 const uint8 salt[LINK_SALT_LENGTH]) { 79 const uint8 salt[LINK_SALT_LENGTH]) {
80 DCHECK(url_len > 0) << "Canonical URLs should not be empty"; 80 DCHECK(url_len > 0) << "Canonical URLs should not be empty";
81 81
82 MD5Context ctx; 82 MD5Context ctx;
83 MD5Init(&ctx); 83 MD5Init(&ctx);
84 MD5Update(&ctx, salt, sizeof(salt)); 84 MD5Update(&ctx, salt, LINK_SALT_LENGTH * sizeof(uint8));
85 MD5Update(&ctx, canonical_url, url_len * sizeof(char)); 85 MD5Update(&ctx, canonical_url, url_len * sizeof(char));
86 86
87 MD5Digest digest; 87 MD5Digest digest;
88 MD5Final(&digest, &ctx); 88 MD5Final(&digest, &ctx);
89 89
90 // This is the same as "return *(Fingerprint*)&digest.a;" but if we do that 90 // This is the same as "return *(Fingerprint*)&digest.a;" but if we do that
91 // direct cast the alignment could be wrong, and we can't access a 64-bit int 91 // direct cast the alignment could be wrong, and we can't access a 64-bit int
92 // on arbitrary alignment on some processors. This reinterpret_casts it 92 // on arbitrary alignment on some processors. This reinterpret_casts it
93 // down to a char array of the same size as fingerprint, and then does the 93 // down to a char array of the same size as fingerprint, and then does the
94 // bit cast, which amounts to a memcpy. This does not handle endian issues. 94 // bit cast, which amounts to a memcpy. This does not handle endian issues.
95 return bit_cast<Fingerprint, uint8[8]>( 95 return bit_cast<Fingerprint, uint8[8]>(
96 *reinterpret_cast<uint8(*)[8]>(&digest.a)); 96 *reinterpret_cast<uint8(*)[8]>(&digest.a));
97 } 97 }
OLDNEW
« no previous file with comments | « chrome/browser/visitedlink/visitedlink_master.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698