Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport 30f8063 #32

Open
wants to merge 2 commits into
base: tomcat-7.0.104-TT
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions java/org/apache/catalina/connector/LocalStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ coyoteRequest.attributeEvent=Exception thrown by attributes event listener
coyoteRequest.authenticate.ise=Cannot call authenticate() after the response has been committed
coyoteRequest.changeSessionId=Cannot change session ID. There is no session associated with this request.
coyoteRequest.chunkedPostTooLarge=Parameters were not parsed because the size of the posted data was too big. Because this request was a chunked request, it could not be processed further. Use the maxPostSize attribute of the connector to resolve this if the application should accept large POSTs.
coyoteRequest.deletePartFailed=Failed to deleted temporary file used for part [{0}]
coyoteRequest.getContextPath.ise=Unable to find match between the canonical context path [{0}] and the URI presented by the user agent [{1}]
coyoteRequest.getInputStream.ise=getReader() has already been called for this request
coyoteRequest.getReader.ise=getInputStream() has already been called for this request
Expand Down
7 changes: 4 additions & 3 deletions java/org/apache/catalina/connector/Request.java
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,9 @@ public void recycle() {
for (Part part: parts) {
try {
part.delete();
} catch (IOException ignored) {
// ApplicationPart.delete() never throws an IOEx
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
log.warn(sm.getString("coyoteRequest.deletePartFailed", part.getName()), t);
}
}
parts = null;
Expand Down Expand Up @@ -536,8 +537,8 @@ public void recycle() {
asyncSupported = null;
if (asyncContext!=null) {
asyncContext.recycle();
asyncContext = null;
}
asyncContext = null;

pathParameters.clear();
}
Expand Down
8 changes: 7 additions & 1 deletion java/org/apache/catalina/core/ApplicationHttpRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.apache.tomcat.util.buf.MessageBytes;
import org.apache.tomcat.util.http.Parameters;
import org.apache.tomcat.util.res.StringManager;
import org.apache.tomcat.util.ExceptionUtils;


/**
Expand Down Expand Up @@ -645,7 +646,12 @@ public boolean isRequestedSessionIdValid() {
*/
public void recycle() {
if (session != null) {
session.endAccess();
try {
session.endAccess();
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
context.getLogger().warn(sm.getString("applicationHttpRequest.sessionEndAccessFail"), t);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions java/org/apache/catalina/core/LocalStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ applicationFilterRegistration.nullInitParam=Unable to set initialisation paramet
applicationFilterRegistration.nullInitParams=Unable to set initialisation parameters for filter due to null name and/or value. Name [{0}], Value [{1}]

applicationHttpRequest.fragmentInDispatchPath=The fragment in dispatch path [{0}] has been removed
applicationHttpRequest.sessionEndAccessFail=Exception triggered ending access to session while recycling request

applicationRequest.badParent=Cannot locate parent Request implementation
applicationRequest.badRequest=Request is not a javax.servlet.ServletRequestWrapper
Expand Down
1 change: 1 addition & 0 deletions java/org/apache/catalina/core/LocalStrings_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ applicationFilterConfig.jmxUnregisterFail=Ha fallado el desregistro JMX para el

applicationFilterRegistration.nullInitParam=No puedo poner el parámetro de inicialización para el filtro debido a un nombre nulo y/o valor. Nombre [{0}], Valor [{1}]
applicationFilterRegistration.nullInitParams=No puedo poner los parámetros de inicialización para el filtro debido a un nombre nulo y/o valor. Nombre [{0}], Valor [{1}]
applicationHttpRequest.sessionEndAccessFail=Excepción disparada acabando acceso a sesión mientras se reciclaba el requerimiento

applicationRequest.badParent=No puedo localizar la implementación de Requerimiento padre
applicationRequest.badRequest=El requerimiento no es un javax.servlet.ServletRequestWrapper
Expand Down
1 change: 1 addition & 0 deletions java/org/apache/catalina/core/LocalStrings_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ applicationFilterConfig.release=Impossible de détruite le filtre nommé [{0}] d

applicationFilterRegistration.nullInitParam=Impossible de fixer le paramètre d''initialisation du filtre, à cause d''un nom ou d''une valeur nulle, nom [{0}], valeur [{1}]
applicationFilterRegistration.nullInitParams=Impossible de fixer les paramètres d''initialisation du filtre, à cause d''un nom ou d''une valeur nulle, nom [{0}], valeur [{1}]
applicationHttpRequest.sessionEndAccessFail=Exception lancée durant l'arrêt de l'accès à la session durant le recyclage de la requête

applicationHttpRequest.fragmentInDispatchPath=Le fragment dans le chemin de dispatch [{0}] a été enlevé

Expand Down
1 change: 1 addition & 0 deletions java/org/apache/catalina/core/LocalStrings_ja.properties
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ applicationFilterConfig.release=タイプ[{1}]の名前[{0}]のフィルタを

applicationFilterRegistration.nullInitParam=NULLの名前や値のためにフィルターの初期化パラメーターを設定できません。 名前[{0}]、値[{1}]
applicationFilterRegistration.nullInitParams=キー [{0}] または値 [{1}] のいずれかが null のためフィルターの初期化パラメータを設定できませんでした。
applicationHttpRequest.sessionEndAccessFail=Exception triggered ending access to session while recycling request

applicationHttpRequest.fragmentInDispatchPath=ディスパッチパス [{0}] 中のフラグメントは除去されました

Expand Down
1 change: 1 addition & 0 deletions java/org/apache/catalina/core/LocalStrings_ko.properties
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ applicationFilterConfig.release=타입이 [{1}](이)고 이름이 [{0}]인 필

applicationFilterRegistration.nullInitParam=이름 또는 값 또는 둘 다 널이어서, 필터를 위한 초기화 파라미터를 설정할 수 없습니다. 이름: [{0}], 값: [{1}]
applicationFilterRegistration.nullInitParams=널인 이름 또는 값 때문에, 필터의 초기화 파라미터를 설정할 수 없습니다. 이름: [{0}], 값: [{1}]
applicationHttpRequest.sessionEndAccessFail=Exception triggered ending access to session while recycling request

applicationHttpRequest.fragmentInDispatchPath=디스패치 경로 [{0}](으)로부터 URI fragment를 제거했습니다.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ applicationFilterConfig.release=失败的销毁过滤器类型为[{1}]名称为[

applicationFilterRegistration.nullInitParam=由于名称和/或值为空,无法为筛选器设置初始化参数。名称[{0}],值[{1}]
applicationFilterRegistration.nullInitParams=由于name和(或)value为null,无法为过滤器设置初始化参数。name为 [{0}],value为 [{1}]
applicationHttpRequest.sessionEndAccessFail=Exception triggered ending access to session while recycling request

applicationHttpRequest.fragmentInDispatchPath=调度路径[{0}]中的片段已被删除

Expand Down
2 changes: 1 addition & 1 deletion java/org/apache/coyote/http11/InternalAprInputBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ private boolean parseHeader() throws IOException {
headers.removeHeader(headers.size() - 1);
skipLine(lineStart, start);
return true;
} else if (chr != Constants.HT && HttpParser.isControl(chr)) {
} else if (HttpParser.isControl(chr) && chr != Constants.HT) {
// Invalid value
// Delete the header (it will be the most recent one)
headers.removeHeader(headers.size() - 1);
Expand Down
2 changes: 1 addition & 1 deletion java/org/apache/coyote/http11/InternalInputBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ private boolean parseHeader() throws IOException {
// Invalid value - also need to delete header
skipLine(lineStart, start, true);
return true;
} else if (chr != Constants.HT && HttpParser.isControl(chr)) {
} else if (HttpParser.isControl(chr) && chr != Constants.HT) {
// Invalid value - also need to delete header
skipLine(lineStart, start, true);
return true;
Expand Down
2 changes: 1 addition & 1 deletion java/org/apache/coyote/http11/InternalNioInputBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ private HeaderParseStatus parseHeader()
} else if (prevChr == Constants.CR) {
// Invalid value - also need to delete header
return skipLine(true);
} else if (chr != Constants.HT && HttpParser.isControl(chr)) {
} else if (HttpParser.isControl(chr) && chr != Constants.HT) {
// Invalid value - also need to delete header
return skipLine(true);
} else if (chr == Constants.SP || chr == Constants.HT) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.tomcat.util.buf.MessageBytes;
import org.apache.tomcat.util.http.MimeHeaders;
import org.apache.tomcat.util.res.StringManager;
import org.apache.tomcat.util.http.parser.HttpParser;

/**
* Chunked input filter. Parses chunked data according to
Expand Down Expand Up @@ -500,6 +501,9 @@ private boolean parseHeader() throws IOException {

if (chr == Constants.COLON) {
colon = true;
} else if (!HttpParser.isToken(chr)) {
// Non-token characters are illegal in header names
throw new IOException(sm.getString("chunkedInputFilter.invalidTrailerHeaderName"));
} else {
trailingHeaders.append(chr);
}
Expand Down Expand Up @@ -561,7 +565,9 @@ private boolean parseHeader() throws IOException {
if (chr == Constants.CR || chr == Constants.LF) {
parseCRLF(true);
eol = true;
} else if (chr == Constants.SP) {
} else if (HttpParser.isControl(chr) && chr != Constants.HT) {
throw new IOException(sm.getString("chunkedInputFilter.invalidTrailerHeaderValue"));
} else if (chr == Constants.SP || chr == Constants.HT) {
trailingHeaders.append(chr);
} else {
trailingHeaders.append(chr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ chunkedInputFilter.invalidCrlfNoData=Invalid end of line sequence (no data avail
chunkedInputFilter.invalidHeader=Invalid chunk header
chunkedInputFilter.maxExtension=maxExtensionSize exceeded
chunkedInputFilter.maxTrailer=maxTrailerSize exceeded

chunkedInputFilter.invalidTrailerHeaderName=Invalid trailer header name (non-token character in name)
chunkedInputFilter.invalidTrailerHeaderValue=Invalid trailer header value (control character in value)
inputFilter.maxSwallow=maxSwallowSize exceeded
11 changes: 10 additions & 1 deletion java/org/apache/tomcat/util/buf/B2CConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
import java.nio.charset.CoderResult;
import java.nio.charset.CodingErrorAction;
import java.util.Locale;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
import org.apache.tomcat.util.ExceptionUtils;

import org.apache.tomcat.util.res.StringManager;

Expand All @@ -33,6 +36,7 @@
*/
public class B2CConverter {

private static final Log log = LogFactory.getLog(B2CConverter.class);
private static final StringManager sm =
StringManager.getManager(Constants.Package);

Expand Down Expand Up @@ -133,7 +137,12 @@ public B2CConverter(String encoding, boolean replaceOnError)
* Reset the decoder state.
*/
public void recycle() {
decoder.reset();
try {
decoder.reset();
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
log.warn(sm.getString("b2cConverter.decoderResetFail", decoder.charset()), t);
}
leftovers.position(0);
}

Expand Down
13 changes: 12 additions & 1 deletion java/org/apache/tomcat/util/buf/C2BConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CoderResult;
import java.nio.charset.CodingErrorAction;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
import org.apache.tomcat.util.ExceptionUtils;
import org.apache.tomcat.util.res.StringManager;

/**
* NIO based character encoder.
*/
public final class C2BConverter {

private static final Log log = LogFactory.getLog(C2BConverter.class);
private static final StringManager sm = StringManager.getManager(C2BConverter.class);
CharsetEncoder encoder = null;
ByteBuffer bb = null;
CharBuffer cb = null;
Expand All @@ -51,7 +57,12 @@ public C2BConverter(String encoding) throws IOException {
* Reset the encoder state.
*/
public void recycle() {
encoder.reset();
try {
encoder.reset();
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
log.warn(sm.getString("c2bConverter.decoderResetFail", encoder.charset()), t);
}
leftovers.position(0);
}

Expand Down
2 changes: 2 additions & 0 deletions java/org/apache/tomcat/util/buf/LocalStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
# limitations under the License.

b2cConverter.unknownEncoding=The character encoding [{0}] is not supported
b2cConverter.decoderResetFail=Failed to reset instance of decoder for character set [{0}]

c2bConverter.recycleFailed=Failed to recycle the C2B Converter. Creating new BufferedWriter, WriteConvertor and IntermediateOutputStream.
c2bConverter.encoderResetFail=Failed to reset instance of encoder for character set [{0}]

encodedSolidusHandling.invalid=The value [{0}] is not recognised

Expand Down
7 changes: 7 additions & 0 deletions webapps/docs/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@
<code>RemoteIpFilter</code> determines that this request was submitted
via a secure channel. (lihan)
</fix>
<add>
Improve handling of failures within <code>recycle()</code> methods.
(markt)
</add>
</changelog>
</subsection>
<subsection name="Coyote">
Expand All @@ -154,6 +158,9 @@
Include the problematic data in the error message when reporting that
the provided request line contains an invalid component. (markt)
</fix>
<fix>
Align validation of HTTP trailer fields with standard fields. (markt)
</fix>
</changelog>
</subsection>
<subsection name="Jasper">
Expand Down
Loading