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

Unified Diff: net/base/ip_address_number.h

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: fixes 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
Index: net/base/ip_address_number.h
diff --git a/net/base/ip_address_number.h b/net/base/ip_address_number.h
index 2671a24d653d5fd1b1a75958a304433fde2e4046..4434fa05352053c4ffe9cc5ed17d569e02f008af 100644
--- a/net/base/ip_address_number.h
+++ b/net/base/ip_address_number.h
@@ -37,12 +37,14 @@ static const size_t kIPv6AddressSize = 16;
NET_EXPORT bool IsIPAddressReserved(const IPAddressNumber& address);
// Returns the string representation of an IP address.
-// For example: "192.168.0.1" or "::1".
+// For example: "192.168.0.1" or "::1". Returns the empty string when |address|
+// is invalid.
NET_EXPORT std::string IPAddressToString(const uint8_t* address,
size_t address_len);
// Returns the string representation of an IP address along with its port.
-// For example: "192.168.0.1:99" or "[::1]:80".
+// For example: "192.168.0.1:99" or "[::1]:80". Returns the empty string when
+// |address| is invalid (the port will be ignored).
NET_EXPORT std::string IPAddressToStringWithPort(const uint8_t* address,
size_t address_len,
uint16_t port);

Powered by Google App Engine
This is Rietveld 408576698