couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject git commit: COUCHDB-1512 - Validate bind address
Date Mon, 30 Jul 2012 11:47:00 GMT
Updated Branches:
  refs/heads/master 0e9c5a5af -> 09ead8a07


COUCHDB-1512 - Validate bind address

This patch validate the bind_address value before attempting to bind
the mochiweb socket, giving an 'invalid_bind_address' error. This
should help users who have specified a hostname or made a typo as the
original error was less helpful.

Fix as suggested by Dave Cottlehuber.


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/09ead8a0
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/09ead8a0
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/09ead8a0

Branch: refs/heads/master
Commit: 09ead8a070050141d8661500fc86e37e1e6a6c9a
Parents: 0e9c5a5
Author: Robert Newson <rnewson@apache.org>
Authored: Mon Jul 30 12:46:35 2012 +0100
Committer: Robert Newson <rnewson@apache.org>
Committed: Mon Jul 30 12:46:35 2012 +0100

----------------------------------------------------------------------
 src/couchdb/couch_httpd.erl |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/09ead8a0/src/couchdb/couch_httpd.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl
index 7329c3b..9bdc08d 100644
--- a/src/couchdb/couch_httpd.erl
+++ b/src/couchdb/couch_httpd.erl
@@ -97,6 +97,7 @@ start_link(Name, Options) ->
     % will restart us and then we will pick up the new settings.
 
     BindAddress = couch_config:get("httpd", "bind_address", any),
+    validate_bind_address(BindAddress),
     DefaultSpec = "{couch_httpd_db, handle_request}",
     DefaultFun = make_arity_1_fun(
         couch_config:get("httpd", "default_handler", DefaultSpec)
@@ -1088,4 +1089,8 @@ partial_find(B, D, N, K) ->
             partial_find(B, D, 1 + N, K - 1)
     end.
 
-
+validate_bind_address(Address) ->
+    case inet_parse:address(Address) of
+        {ok, _} -> ok;
+        _ -> throw({error, invalid_bind_address})
+    end.


Mime
View raw message