Commit 206cba91 authored by Rouslan Solomakhin's avatar Rouslan Solomakhin Committed by Commit Bot

[Payments] Don't log non-unicode in parser.

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: default avatarGanggui Tang <gogerald@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521445}
parent d5f1f082
......@@ -25,6 +25,11 @@ 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 "
......@@ -32,11 +37,6 @@ std::vector<uint8_t> FingerprintStringToByteArray(const std::string& input) {
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment