Commit fd86da2f authored by Vadym Doroshenko's avatar Vadym Doroshenko Committed by Commit Bot

Quick fix for crash during phone parsing.

This CL fixes out of range access, when by some reasons during the
phone parsing, libphonenumber returns that national code is longer that
the parsed string. Probably the reasons are some incorrect treating of
non-ASCII characters.

Bug: 895578
Change-Id: I2f0a7622453191778907a8f54e74e35a1484765b
Reviewed-on: https://chromium-review.googlesource.com/c/1286136
Commit-Queue: Vadym Doroshenko <dvadym@chromium.org>
Reviewed-by: default avatarVaclav Brozek <vabr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600366}
parent bd09ecb2
...@@ -166,6 +166,13 @@ bool ParsePhoneNumber(const base::string16& value, ...@@ -166,6 +166,13 @@ bool ParsePhoneNumber(const base::string16& value,
if (destination_length > area_length) if (destination_length > area_length)
area_length = destination_length; area_length = destination_length;
if (area_length >= static_cast<int>(national_significant_number.size())) {
// For some non-ASCII strings |destination_length| is bigger than phone
// string size. It might be because of incorrect treating of non-ASCII
// characters.
return false;
}
std::string area_code; std::string area_code;
std::string subscriber_number; std::string subscriber_number;
if (area_length > 0) { if (area_length > 0) {
......
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