Author: remy.maucherat(a)jboss.com
Date: 2014-03-13 10:32:46 -0400 (Thu, 13 Mar 2014)
New Revision: 2385
Modified:
branches/7.3.x/src/main/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java
branches/7.3.x/src/main/java/org/apache/tomcat/util/http/fileupload/MultipartStream.java
branches/7.3.x/src/main/java/org/jboss/web/FileUploadMessages.java
Log:
Port fileupload fix.
Modified:
branches/7.3.x/src/main/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java
===================================================================
---
branches/7.3.x/src/main/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java 2014-03-13
10:59:45 UTC (rev 2384)
+++
branches/7.3.x/src/main/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java 2014-03-13
14:32:46 UTC (rev 2385)
@@ -795,7 +795,11 @@
notifier = new MultipartStream.ProgressNotifier(listener,
ctx.getContentLength());
- multi = new MultipartStream(input, boundary, notifier);
+ try {
+ multi = new MultipartStream(input, boundary, notifier);
+ } catch (IllegalArgumentException iae) {
+ throw new
InvalidContentTypeException(MESSAGES.invalidBoundary(CONTENT_TYPE), iae);
+ }
multi.setHeaderEncoding(charEncoding);
skipPreamble = true;
@@ -969,7 +973,7 @@
* detail message.
*/
public InvalidContentTypeException() {
- // Nothing to do.
+ super();
}
/**
@@ -981,8 +985,12 @@
public InvalidContentTypeException(String message) {
super(message);
}
- }
+ public InvalidContentTypeException(String message, Exception cause) {
+ super(message, cause);
+ }
+ }
+
/**
* Thrown to indicate an IOException.
*/
Modified:
branches/7.3.x/src/main/java/org/apache/tomcat/util/http/fileupload/MultipartStream.java
===================================================================
---
branches/7.3.x/src/main/java/org/apache/tomcat/util/http/fileupload/MultipartStream.java 2014-03-13
10:59:45 UTC (rev 2384)
+++
branches/7.3.x/src/main/java/org/apache/tomcat/util/http/fileupload/MultipartStream.java 2014-03-13
14:32:46 UTC (rev 2385)
@@ -302,8 +302,11 @@
// We prepend CR/LF to the boundary to chop trailing CR/LF from
// body-data tokens.
- this.boundary = new byte[boundary.length + BOUNDARY_PREFIX.length];
this.boundaryLength = boundary.length + BOUNDARY_PREFIX.length;
+ if (bufSize < this.boundaryLength + 1) {
+ throw MESSAGES.multipartStreamBufferSizeTooSmall();
+ }
+ this.boundary = new byte[this.boundaryLength];
this.keepRegion = this.boundary.length;
System.arraycopy(BOUNDARY_PREFIX, 0, this.boundary, 0,
BOUNDARY_PREFIX.length);
Modified: branches/7.3.x/src/main/java/org/jboss/web/FileUploadMessages.java
===================================================================
--- branches/7.3.x/src/main/java/org/jboss/web/FileUploadMessages.java 2014-03-13 10:59:45
UTC (rev 2384)
+++ branches/7.3.x/src/main/java/org/jboss/web/FileUploadMessages.java 2014-03-13 14:32:46
UTC (rev 2385)
@@ -18,7 +18,6 @@
package org.jboss.web;
-import org.jboss.logging.Cause;
import org.jboss.logging.Message;
import org.jboss.logging.MessageBundle;
import org.jboss.logging.Messages;
@@ -122,4 +121,10 @@
@Message(id = 8228, value = "Invalid file name: %s")
String invalidFileName(String fileName);
+ @Message(id = 8229, value = "The boundary specified in the %s header is too
long")
+ String invalidBoundary(String header);
+
+ @Message(id = 8230, value = "The buffer size specified for the MultipartStream
is too small")
+ IllegalArgumentException multipartStreamBufferSizeTooSmall();
+
}