summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Newson <rnewson@apache.org>2011-01-12 10:45:14 +0000
committerRobert Newson <rnewson@apache.org>2011-01-12 10:45:14 +0000
commit3674f2a2ef778bdf211426d9e804192e22cd26ad (patch)
tree061cdcd540d8568de5a7f0d49ba6a5c8dc3cf893 /src
parent43da5dcc08fd83b6255f14d7a97ea177018f07e6 (diff)
ensure write_streamed_attachment bails on negative LenLeft values
While Filipe has identified the fix for COUCHDB-1021, this patch will ensure that no other bug will cause negative values to be passed to this function, in turn leading to database inflation problems, etc. git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.0.x@1058058 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/couchdb/couch_db.erl2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/couchdb/couch_db.erl b/src/couchdb/couch_db.erl
index f005a2ea..b7055b5c 100644
--- a/src/couchdb/couch_db.erl
+++ b/src/couchdb/couch_db.erl
@@ -920,7 +920,7 @@ with_stream(Fd, #att{md5=InMd5,type=Type,encoding=Enc}=Att, Fun) ->
write_streamed_attachment(_Stream, _F, 0) ->
ok;
-write_streamed_attachment(Stream, F, LenLeft) ->
+write_streamed_attachment(Stream, F, LenLeft) when LenLeft > 0 ->
Bin = F(),
ok = couch_stream:write(Stream, Bin),
write_streamed_attachment(Stream, F, LenLeft - size(Bin)).