summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authordougk <dougk@chromium.org>2015-02-18 15:54:37 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-18 23:55:19 +0000
commit5ec46dd5b1a8840be3dbd8800419736a40a85bd9 (patch)
treea780f71878fc989db3a07a0d2bbef2bedda77b11 /net
parentac860c7f9ad3a532a6cf0684aaa270d9c0ef36a6 (diff)
downloadchromium_src-5ec46dd5b1a8840be3dbd8800419736a40a85bd9.zip
chromium_src-5ec46dd5b1a8840be3dbd8800419736a40a85bd9.tar.gz
chromium_src-5ec46dd5b1a8840be3dbd8800419736a40a85bd9.tar.bz2
quic_client should check return codes when parsing command-line flags.
This is a minimal fix to prevent silently doing the wrong thing. A better fix would resolve names, and use the URL itself as a fallback. BUG=none Review URL: https://codereview.chromium.org/938853002 Cr-Commit-Position: refs/heads/master@{#316925}
Diffstat (limited to 'net')
-rw-r--r--net/quic/quic_server_bin.cc3
-rw-r--r--net/tools/quic/quic_client_bin.cc13
2 files changed, 14 insertions, 2 deletions
diff --git a/net/quic/quic_server_bin.cc b/net/quic/quic_server_bin.cc
index 320f3da..e7c2a6c 100644
--- a/net/quic/quic_server_bin.cc
+++ b/net/quic/quic_server_bin.cc
@@ -51,6 +51,9 @@ int main(int argc, char *argv[]) {
int port;
if (base::StringToInt(line->GetSwitchValueASCII("port"), &port)) {
FLAGS_port = port;
+ } else {
+ LOG(ERROR) << "--port must be an integer\n";
+ return 1;
}
}
diff --git a/net/tools/quic/quic_client_bin.cc b/net/tools/quic/quic_client_bin.cc
index 3800944..66517ca 100644
--- a/net/tools/quic/quic_client_bin.cc
+++ b/net/tools/quic/quic_client_bin.cc
@@ -128,6 +128,9 @@ int main(int argc, char *argv[]) {
int port;
if (base::StringToInt(line->GetSwitchValueASCII("port"), &port)) {
FLAGS_port = port;
+ } else {
+ std::cerr << "--port must be an integer\n";
+ return 1;
}
}
if (line->HasSwitch("body")) {
@@ -170,8 +173,14 @@ int main(int argc, char *argv[]) {
GURL url(urls[0]);
string host = FLAGS_host;
// TODO(rtenneti): get ip_addr from hostname by doing host resolution.
- CHECK(!host.empty());
- net::ParseIPLiteralToNumber(host, &ip_addr);
+ if (host.empty()) {
+ LOG(ERROR) << "--host must be specified\n";
+ return 1;
+ }
+ if (!net::ParseIPLiteralToNumber(host, &ip_addr)) {
+ LOG(ERROR) << "--host could not be parsed as an IP address\n";
+ return 1;
+ }
string host_port = net::IPAddressToStringWithPort(ip_addr, FLAGS_port);
VLOG(1) << "Resolved " << host << " to " << host_port << endl;