Skip to content

Commit

Permalink
[Payments] Don't log non-unicode in parser.
Browse files Browse the repository at this point in the history
Before this patch, parsing non-unicode fingerprints resulted in a failed
assertion when logging the string to terminal.

This patch adds a check for non-ASCII input string. A non-ASCII string
is not logged to terminal.

After this patch, parsing non-ASCII fingerprints does not result in a
failed assertion, because the non-ASCII fingerprint is not logged to
terminal.

Test: FingerprintParserTest.MustBeASCII
Bug: 791584
Change-Id: I0317203c1dae5a048008df074fee77982838fa1c
Reviewed-on: https://chromium-review.googlesource.com/806317
Commit-Queue: Rouslan Solomakhin <rouslan@chromium.org>
Reviewed-by: Ganggui Tang <gogerald@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521445}
  • Loading branch information
rsolomakhin authored and Commit Bot committed Dec 4, 2017
1 parent d5f1f08 commit 206cba9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions components/payments/content/utility/fingerprint_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ uint8_t HexDigitToByte(char c) {

std::vector<uint8_t> FingerprintStringToByteArray(const std::string& input) {
std::vector<uint8_t> output;
if (!base::IsStringASCII(input)) {
LOG(ERROR) << "Fingerprint should be an ASCII string.";
return output;
}

const size_t kLength = 32 * 3 - 1;
if (input.size() != kLength) {
LOG(ERROR) << "Fingerprint \"" << input << "\" should contain exactly "
<< kLength << " characters.";
return output;
}

if (!base::IsStringASCII(input)) {
LOG(ERROR) << "Fingerprint \"" << input << "\" should be ASCII.";
return output;
}

for (size_t i = 0; i < input.size(); i += 3) {
if (i < input.size() - 2 && input[i + 2] != ':') {
LOG(ERROR) << "Bytes in fingerprint \"" << input
Expand Down

0 comments on commit 206cba9

Please sign in to comment.