Fix potential StackOverFlowError on regexp (#1193)

Fix potential StackOverFlowError on regexp
This commit is contained in:
Tyler Benson 2020-01-29 13:19:40 -05:00 committed by GitHub
commit 8757ba0a81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 2 deletions

View File

@ -42,16 +42,25 @@ public class TraceConfigInstrumentation implements Instrumenter {
+ PACKAGE_CLASS_NAME_REGEX
+ "\\["
+ METHOD_LIST_REGEX
+ "\\]\\s*;?\\s*";
+ "\\]";
private final Map<String, Set<String>> classMethodsToTrace;
private boolean validateConfigString(String configString) {
for (String segment : configString.split(";")) {
if (!segment.trim().matches(CONFIG_FORMAT)) {
return false;
}
}
return true;
}
public TraceConfigInstrumentation() {
final String configString = Config.get().getTraceMethods();
if (configString == null || configString.trim().isEmpty()) {
classMethodsToTrace = Collections.emptyMap();
} else if (!configString.matches(CONFIG_FORMAT)) {
} else if (!validateConfigString(configString)) {
log.warn(
"Invalid trace method config '{}'. Must match 'package.Class$Name[method1,method2];*'.",
configString);