Codebase list tomcat9 / 78576fd
CVE-2021-30640: Fix NullPointerException If no userRoleAttribute is specified in the user's Realm configuration its default value will be null. This will cause a NPE in the methods doFilterEscaping and doAttributeValueEscaping. This is upstream bug https://bz.apache.org/bugzilla/show_bug.cgi?id=65308 Markus Koschany 2 years ago
1 changed file(s) with 11 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
1111 Origin: https://github.com/apache/tomcat/commit/329932012d3a9b95fde0b18618416e659ecffdc0
1212 Origin: https://github.com/apache/tomcat/commit/3ce84512ed8783577d9945df28da5a033465b945
1313 ---
14 java/org/apache/catalina/realm/JNDIRealm.java | 137 +++++++++++++++++++--
14 java/org/apache/catalina/realm/JNDIRealm.java | 143 +++++++++++++++++++--
1515 .../realm/TestJNDIRealmAttributeValueEscape.java | 86 +++++++++++++
16 2 files changed, 213 insertions(+), 10 deletions(-)
16 2 files changed, 219 insertions(+), 10 deletions(-)
1717 create mode 100644 test/org/apache/catalina/realm/TestJNDIRealmAttributeValueEscape.java
1818
1919 diff --git a/java/org/apache/catalina/realm/JNDIRealm.java b/java/org/apache/catalina/realm/JNDIRealm.java
20 index 7e2d578..358d008 100644
20 index 7e2d578..2a03307 100644
2121 --- a/java/org/apache/catalina/realm/JNDIRealm.java
2222 +++ b/java/org/apache/catalina/realm/JNDIRealm.java
2323 @@ -1633,8 +1633,11 @@ public class JNDIRealm extends RealmBase {
113113 isRoleSearchAsUser());
114114
115115 try {
116 @@ -2823,10 +2842,36 @@ public class JNDIRealm extends RealmBase {
116 @@ -2823,10 +2842,39 @@ public class JNDIRealm extends RealmBase {
117117 * ) -> \29
118118 * \ -> \5c
119119 * \0 -> \00
147147 + * @return String the escaped/encoded result
148148 + */
149149 + protected String doFilterEscaping(String inString) {
150 + if (inString == null) {
151 + return null;
152 + }
150153 StringBuilder buf = new StringBuilder(inString.length());
151154 for (int i = 0; i < inString.length(); i++) {
152155 char c = inString.charAt(i);
153 @@ -2916,6 +2961,78 @@ public class JNDIRealm extends RealmBase {
156 @@ -2916,6 +2964,81 @@ public class JNDIRealm extends RealmBase {
154157 }
155158
156159
162165 + * @return The string representation of the attribute value
163166 + */
164167 + protected String doAttributeValueEscaping(String input) {
168 + if (input == null) {
169 + return null;
170 + }
165171 + int len = input.length();
166172 + StringBuilder result = new StringBuilder();
167173 +