You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by Benoit Chesneau <bc...@gmail.com> on 2012/07/30 14:43:00 UTC

Re: git commit: COUCHDB-1512 - Validate bind address

Wasn't mochiweb already throwing an error ?

https://github.com/apache/couchdb/blob/master/src/mochiweb/mochiweb_socket_server.erl#L84

- benoit
On Mon, Jul 30, 2012 at 1:47 PM,  <rn...@apache.org> wrote:
> 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 <rn...@apache.org>
> Authored: Mon Jul 30 12:46:35 2012 +0100
> Committer: Robert Newson <rn...@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.
>