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

Unified Diff: net/base/ip_address.cc

Issue 1828103002: Extend net/base/parse_number.h for parsing of negative numbers, and determining if there was overflo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@proxy_num
Patch Set: fix comments Created 4 years, 8 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/host_port_pair.cc ('k') | net/base/parse_number.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/ip_address.cc
diff --git a/net/base/ip_address.cc b/net/base/ip_address.cc
index 722e3703f35b0b6ae58c6e0db3e46e088017ec6f..dc43f81e01d80315d86c9bdcceffff50827399e7 100644
--- a/net/base/ip_address.cc
+++ b/net/base/ip_address.cc
@@ -180,16 +180,15 @@ bool ParseCIDRBlock(const std::string& cidr_literal,
return false;
// Parse the prefix length.
- int number_of_bits = -1;
- if (!ParseNonNegativeDecimalInt(parts[1], &number_of_bits))
+ uint32_t number_of_bits;
+ if (!ParseUint32(parts[1], &number_of_bits))
return false;
// Make sure the prefix length is in a valid range.
- if (number_of_bits < 0 ||
- number_of_bits > static_cast<int>(ip_address->size() * 8))
+ if (number_of_bits > ip_address->size() * 8)
return false;
- *prefix_length_in_bits = static_cast<size_t>(number_of_bits);
+ *prefix_length_in_bits = number_of_bits;
return true;
}
« no previous file with comments | « net/base/host_port_pair.cc ('k') | net/base/parse_number.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698