Skip to content

Commit

Permalink
Address outstanding comments from CL 10384140
Browse files Browse the repository at this point in the history
This adds some clarifying comments, no code-changes here.

BUG=none
TEST=none


Review URL: https://chromiumcodereview.appspot.com/10406022

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137695 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
lambroslambrou@chromium.org committed May 17, 2012
1 parent 6365032 commit c8838bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions base/base64.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand All @@ -14,7 +14,9 @@ bool Base64Encode(const StringPiece& input, std::string* output) {

// null terminates result since result is base64 text!
int input_size = static_cast<int>(input.size());
int output_size= modp_b64_encode(&(temp[0]), input.data(), input_size);

// modp_b64_encode_len() returns at least 1, so temp[0] is safe to use.
int output_size = modp_b64_encode(&(temp[0]), input.data(), input_size);
if (output_size < 0)
return false;

Expand Down
5 changes: 5 additions & 0 deletions remoting/host/me2me_preference_pane.mm
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ bool IsPinValid(const std::string& pin, const std::string& host_id,
int hash_base64_size = static_cast<int>(hash_base64.size());
std::string hash;
hash.resize(modp_b64_decode_len(hash_base64_size));

// modp_b64_decode_len() returns at least 1, so hash[0] is safe here.
int hash_size = modp_b64_decode(&(hash[0]), hash_base64.data(),
hash_base64_size);
if (hash_size < 0) {
Expand All @@ -99,6 +101,9 @@ bool IsPinValid(const std::string& pin, const std::string& host_id,
pin.data(), pin.size(),
&(computed_hash[0]));

// Normally, a constant-time comparison function would be used, but it is
// unnecessary here as the "secret" is already readable by the user
// supplying input to this routine.
return computed_hash == hash;
}

Expand Down

0 comments on commit c8838bf

Please sign in to comment.