Skip to content

Commit

Permalink
Tokens should not contain or end at ')'
Browse files Browse the repository at this point in the history
  • Loading branch information
markt-asf committed Jul 4, 2023
1 parent 3ca1ca2 commit 8102eab
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
4 changes: 1 addition & 3 deletions java/org/apache/catalina/valves/ExtendedAccessLogValve.java
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,7 @@ public String getToken() throws IOException {
parameter = true;
return result;
case ')':
result = buf.toString();
buf.setLength(0);
break;
throw new IOException(sm.getString("patternTokenizer.unexpectedParenthesis"));
default:
buf.append((char) c);
}
Expand Down
2 changes: 2 additions & 0 deletions java/org/apache/catalina/valves/LocalStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ http.511.reason=Network Authentication Required
jdbcAccessLogValve.close=Failed to close database
jdbcAccessLogValve.exception=Exception performing insert access entry

patternTokenizer.unexpectedParenthesis=Unexpected ')' in pattern

persistentValve.acquireFailed=The request for [{0}] did not obtain the per session Semaphore as no permit was available
persistentValve.acquireInterrupted=The request for [{0}] did not obtain the per session Semaphore as it was interrupted while waiting for a permit
persistentValve.filter.failure=Unable to compile filter=[{0}]
Expand Down
32 changes: 32 additions & 0 deletions test/org/apache/catalina/valves/TestPatternTokenizer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.catalina.valves;

import java.io.IOException;

import org.junit.Test;

import org.apache.catalina.valves.ExtendedAccessLogValve.PatternTokenizer;

public class TestPatternTokenizer {

@Test(expected = IOException.class)
public void doUnexpectedParenthesis() throws IOException {
String input = "a)aa)";
PatternTokenizer tokenizer = new PatternTokenizer(input);
tokenizer.getToken();
}
}
4 changes: 4 additions & 0 deletions webapps/docs/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@
Fix potential database connection leaks in
<code>DataSourceUserDatabase</code> identified by Coverity Scan. (markt)
</fix>
<fix>
Make parsing of <code>ExtendedAccessLogValve</code> patterns more
robust. (markt)
</fix>
</changelog>
</subsection>
</section>
Expand Down

0 comments on commit 8102eab

Please sign in to comment.