couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject svn commit: r1058055 - /couchdb/trunk/src/couchdb/couch_db.erl
Date Wed, 12 Jan 2011 10:44:17 GMT
Author: rnewson
Date: Wed Jan 12 10:44:16 2011
New Revision: 1058055

URL: http://svn.apache.org/viewvc?rev=1058055&view=rev
Log:
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.

Modified:
    couchdb/trunk/src/couchdb/couch_db.erl

Modified: couchdb/trunk/src/couchdb/couch_db.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_db.erl?rev=1058055&r1=1058054&r2=1058055&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_db.erl Wed Jan 12 10:44:16 2011
@@ -944,7 +944,7 @@ with_stream(Fd, #att{md5=InMd5,type=Type
 
 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)).



Mime
View raw message