Skip to content

Commit

Permalink
Guard against polynomial regular expression used on uncontrolled data in
Browse files Browse the repository at this point in the history
VMSVersioningFTPEntryParser
  • Loading branch information
garydgregory committed Feb 23, 2024
1 parent 695f142 commit f6717be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ The <action> type attribute can be add,update,fix,remove.
<release version="3.11.0" date="202Y-MM-DD" description="Maintenance and bug fix release (Java 8 or above).">
<!-- FIX -->
<action type="fix" dev="ggregory" due-to="Gary Gregory">Precompile regular expression in UnixFTPEntryParser.preParse(List&lt;String&gt;).</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Guard against polynomial regular expression used on uncontrolled data in VMSVersioningFTPEntryParser.</action>
<!-- ADD -->
<action type="add" issue="NET-726" dev="ggregory" due-to="PJ Fanning, Gary Gregory">Add protected getters to FTPSClient #204.</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">Add SubnetUtils.toString().</action>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@
*/
public class VMSVersioningFTPEntryParser extends VMSFTPEntryParser {

private static final String REGEX = "(.*?);([0-9]+)\\s*.*";
/**
* Guard against polynomial regular expression used on uncontrolled data.
* Don't look for more than 20 digits for the version.
* Don't look for more than 80 spaces after the version.
* Don't look for more than 80 characters after the spaces.
*/
private static final String REGEX = "(.*?);([0-9]{1,20})\\s{0,80}.{0,80}";
private static final Pattern PATTERN = Pattern.compile(REGEX);

/**
Expand Down

0 comments on commit f6717be

Please sign in to comment.