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

Unified Diff: net/base/ip_address_number.cc

Issue 1692353002: Make IP Address related functions return the empty string when used on an invalid address. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/ip_address_number.h ('k') | net/base/ip_address_number_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/ip_address_number.cc
diff --git a/net/base/ip_address_number.cc b/net/base/ip_address_number.cc
index 1e44b7d3b1ebcc74873fa762eb0ced94411c188d..07dbc56fec09729774dcab2e1593bd9fa2427dba 100644
--- a/net/base/ip_address_number.cc
+++ b/net/base/ip_address_number.cc
@@ -103,7 +103,7 @@ std::string IPAddressToString(const uint8_t* address, size_t address_len) {
} else if (address_len == kIPv6AddressSize) {
url::AppendIPv6Address(address, &output);
} else {
- CHECK(false) << "Invalid IP address with length: " << address_len;
+ return std::string();
}
output.Complete();
@@ -113,6 +113,9 @@ std::string IPAddressToString(const uint8_t* address, size_t address_len) {
std::string IPAddressToStringWithPort(const uint8_t* address,
size_t address_len,
uint16_t port) {
+ if (address_len != kIPv4AddressSize && address_len != kIPv6AddressSize)
eroman 2016/02/16 19:48:52 How about instead, put the following line after IP
martijnc 2016/02/16 22:02:00 Done.
+ return std::string();
+
std::string address_str = IPAddressToString(address, address_len);
if (address_len == kIPv6AddressSize) {
« no previous file with comments | « net/base/ip_address_number.h ('k') | net/base/ip_address_number_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698