Bug 802459 - OOM crash if attaching too large a file with Filelink. r=m_kato,a=Standard8
authorMike Conley <mconley@mozilla.com>
Fri, 26 Oct 2012 10:29:41 -0400
changeset 13518 d0a73868cef89fa9799d416c66d503b287681bca
parent 13517 a8fbe8ea256606754fc5d10e89e76ff51caf973c
child 13519 86cf289595ef3f52bf8ffdad29f312b6b2934193
push idunknown
push userunknown
push dateunknown
reviewersm_kato, Standard8
bugs802459
Bug 802459 - OOM crash if attaching too large a file with Filelink. r=m_kato,a=Standard8
mail/components/cloudfile/nsBox.js
mail/components/cloudfile/nsUbuntuOne.js
mail/components/cloudfile/nsYouSendIt.js
--- a/mail/components/cloudfile/nsBox.js
+++ b/mail/components/cloudfile/nsBox.js
@@ -850,17 +850,17 @@ nsBoxFileUploader.prototype = {
       this._fstream.init(this._tempFile, -1, 0, 0);
       this._fstream.close();
       // I don't trust re-using the old fstream.
       this._fstream = Cc["@mozilla.org/network/file-input-stream;1"]
                      .createInstance(Ci.nsIFileInputStream);
       this._fstream.init(this._tempFile, -1, 0, 0);
       this._bufStream = Cc["@mozilla.org/network/buffered-input-stream;1"]
                         .createInstance(Ci.nsIBufferedInputStream);
-      this._bufStream.init(this._fstream, this._tempFile.fileSize);
+      this._bufStream.init(this._fstream, 4096);
       // nsIXMLHttpRequest's nsIVariant handling requires that we QI
       // to nsIInputStream.
       req.send(this._bufStream.QueryInterface(Ci.nsIInputStream));
     } catch (ex) {
       this.cleanupTempFile();
       this.log.error(ex);
       throw ex;
     }
--- a/mail/components/cloudfile/nsUbuntuOne.js
+++ b/mail/components/cloudfile/nsUbuntuOne.js
@@ -685,17 +685,17 @@ nsUbuntuOneFileUploader.prototype = {
       contentType = "application/octet-stream";
     }
     let headers = [["Content-Type", contentType]];
     let fstream = Cc["@mozilla.org/network/file-input-stream;1"]
                      .createInstance(Ci.nsIFileInputStream);
     fstream.init(this.file, -1, 0, 0);
     let bufStream = Cc["@mozilla.org/network/buffered-input-stream;1"].
       createInstance(Ci.nsIBufferedInputStream);
-    bufStream.init(fstream, this.file.fileSize);
+    bufStream.init(fstream, 4096);
     bufStream = bufStream.QueryInterface(Ci.nsIInputStream);
     this.request = this.ubuntuone._connection.signAndSend(
       url, headers, "PUT", bufStream,
       function(aResponseText, aRequest) {
         this.request = null;
         this.log.info("success putting file " + aResponseText);
         let nodeInfo = JSON.parse(aResponseText);
         this._getShareUrl(nodeInfo);
--- a/mail/components/cloudfile/nsYouSendIt.js
+++ b/mail/components/cloudfile/nsYouSendIt.js
@@ -1067,17 +1067,17 @@ nsYouSendItFileUploader.prototype = {
       this._fstream.init(this._tempFile, -1, 0, 0);
       this._fstream.close();
       // I don't trust re-using the old fstream.
       this._fstream = Cc["@mozilla.org/network/file-input-stream;1"]
                      .createInstance(Ci.nsIFileInputStream);
       this._fstream.init(this._tempFile, -1, 0, 0);
       this._bufStream = Cc["@mozilla.org/network/buffered-input-stream;1"]
                         .createInstance(Ci.nsIBufferedInputStream);
-      this._bufStream.init(this._fstream, this._tempFile.fileSize);
+      this._bufStream.init(this._fstream, 4096);
       // nsIXMLHttpRequest's nsIVariant handling requires that we QI
       // to nsIInputStream.
       req.send(this._bufStream.QueryInterface(Ci.nsIInputStream));
     } catch (ex) {
       this.cleanupTempFile();
       this.log.error(ex);
       throw ex;
     }