You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2016/10/06 21:22:11 UTC

[1/2] couch commit: updated refs/heads/master to bfed196

Repository: couchdb-couch
Updated Branches:
  refs/heads/master fc082b4b2 -> bfed196d4


Add max_document_size checking for multipart PUT requests

Previously multipart/related PUT requests didn't check maximum request sizes.

This commit checks content-length and compares that with the maximum.

This means keeping the current "semantics" of max_document_size which actually
means "max request size". But this makes the check more efficient and can
be done earlier in request processing time.

Jira: COUCHDB-3174


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

Branch: refs/heads/master
Commit: 7dec013e8dc12db718ce124ad07f62b7cd3f7419
Parents: f129308
Author: Nick Vatamaniuc <va...@apache.org>
Authored: Tue Oct 4 02:50:07 2016 -0400
Committer: Nick Vatamaniuc <va...@apache.org>
Committed: Tue Oct 4 02:50:07 2016 -0400

----------------------------------------------------------------------
 src/couch_httpd.erl    | 14 ++++++++++++++
 src/couch_httpd_db.erl |  1 +
 2 files changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/7dec013e/src/couch_httpd.erl
----------------------------------------------------------------------
diff --git a/src/couch_httpd.erl b/src/couch_httpd.erl
index 7c4e573..8e7dfeb 100644
--- a/src/couch_httpd.erl
+++ b/src/couch_httpd.erl
@@ -33,6 +33,8 @@
 -export([http_1_0_keep_alive/2]).
 -export([validate_host/1]).
 -export([validate_bind_address/1]).
+-export([check_max_request_length/1]).
+
 
 -define(HANDLER_NAME_IN_MODULE_POS, 6).
 
@@ -446,6 +448,18 @@ validate_ctype(Req, Ctype) ->
         end
     end.
 
+
+check_max_request_length(Req) ->
+    Len = list_to_integer(header_value(Req, "Content-Length", "0")),
+    MaxLen = config:get_integer("couchdb", "max_document_size", 4294967296),
+    case Len > MaxLen of
+        true ->
+            exit({body_too_large, Len});
+        false ->
+            ok
+    end.
+
+
 % Utilities
 
 partition(Path) ->

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/7dec013e/src/couch_httpd_db.erl
----------------------------------------------------------------------
diff --git a/src/couch_httpd_db.erl b/src/couch_httpd_db.erl
index 965e8fb..c46733f 100644
--- a/src/couch_httpd_db.erl
+++ b/src/couch_httpd_db.erl
@@ -583,6 +583,7 @@ db_doc_req(#httpd{method='PUT'}=Req, Db, DocId) ->
 
     case couch_util:to_list(couch_httpd:header_value(Req, "Content-Type")) of
     ("multipart/related;" ++ _) = ContentType ->
+        couch_chttpd:check_max_request_length(Req),
         {ok, Doc0, WaitFun, Parser} = couch_doc:doc_from_multi_part_stream(
             ContentType, fun() -> receive_request_data(Req) end),
         Doc = couch_doc_from_req(Req, DocId, Doc0),


[2/2] couch commit: updated refs/heads/master to bfed196

Posted by va...@apache.org.
Merge branch 'couchdb-3174'


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

Branch: refs/heads/master
Commit: bfed196d4cade50be6864db71611f0b909cc919b
Parents: fc082b4 7dec013
Author: Nick Vatamaniuc <va...@apache.org>
Authored: Thu Oct 6 17:14:52 2016 -0400
Committer: Nick Vatamaniuc <va...@apache.org>
Committed: Thu Oct 6 17:14:52 2016 -0400

----------------------------------------------------------------------
 src/couch_httpd.erl    | 14 ++++++++++++++
 src/couch_httpd_db.erl |  1 +
 2 files changed, 15 insertions(+)
----------------------------------------------------------------------