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

Unified Diff: runtime/bin/socket_macos.cc

Issue 10917064: Throw an error if the ServerSocket host argument is invalid. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Check exception. Created 8 years, 3 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 | « runtime/bin/socket_linux.cc ('k') | runtime/bin/socket_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/socket_macos.cc
diff --git a/runtime/bin/socket_macos.cc b/runtime/bin/socket_macos.cc
index c57a3bfcf9a8643ff7e7712644c60c1ad50d3cb4..caeb021f12bc9d7bd1ff0b3134a585e1fe639e14 100644
--- a/runtime/bin/socket_macos.cc
+++ b/runtime/bin/socket_macos.cc
@@ -176,6 +176,11 @@ intptr_t ServerSocket::CreateBindListen(const char* host,
intptr_t fd;
struct sockaddr_in server_address;
+ in_addr_t s_addr = TEMP_FAILURE_RETRY(inet_addr(host));
+ if (s_addr == INADDR_NONE) {
+ return -5;
+ }
+
fd = TEMP_FAILURE_RETRY(socket(AF_INET, SOCK_STREAM, 0));
if (fd < 0) {
fprintf(stderr, "Error CreateBind: %s\n", strerror(errno));
@@ -188,7 +193,7 @@ intptr_t ServerSocket::CreateBindListen(const char* host,
server_address.sin_family = AF_INET;
server_address.sin_port = htons(port);
- server_address.sin_addr.s_addr = inet_addr(host);
+ server_address.sin_addr.s_addr = s_addr;
memset(&server_address.sin_zero, 0, sizeof(server_address.sin_zero));
if (TEMP_FAILURE_RETRY(
« no previous file with comments | « runtime/bin/socket_linux.cc ('k') | runtime/bin/socket_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698