Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:15-SP1
tomcat.32131
tomcat-9.0-NPE-JNDIRealm.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File tomcat-9.0-NPE-JNDIRealm.patch of Package tomcat.32131
From: Felix Schumacher <fschumacher@apache.org> Date: Sat, 15 May 2021 14:06:21 +0200 Subject: [PATCH] Guard new escape routines for null values NPE in JNDIRealm, when userRoleAttribute is not set. Bugzilla Id: 63508 --- java/org/apache/catalina/realm/JNDIRealm.java | 6 +++ .../realm/TestJNDIRealmIntegration.java | 42 ++++++++++++++----- webapps/docs/changelog.xml | 8 ++ Index: apache-tomcat-9.0.36-src/java/org/apache/catalina/realm/JNDIRealm.java =================================================================== --- apache-tomcat-9.0.36-src.orig/java/org/apache/catalina/realm/JNDIRealm.java +++ apache-tomcat-9.0.36-src/java/org/apache/catalina/realm/JNDIRealm.java @@ -2789,6 +2789,9 @@ public class JNDIRealm extends RealmBase * @return String the escaped/encoded result */ protected String doFilterEscaping(String inString) { + if (inString == null) { + return null; + } StringBuilder buf = new StringBuilder(inString.length()); for (int i = 0; i < inString.length(); i++) { char c = inString.charAt(i); @@ -2881,6 +2884,9 @@ public class JNDIRealm extends RealmBase * @return The string representation of the attribute value */ protected String doAttributeValueEscaping(String input) { + if (input == null) { + return null; + } int len = input.length(); StringBuilder result = new StringBuilder(); Index: apache-tomcat-9.0.36-src/test/org/apache/catalina/realm/TestJNDIRealmIntegration.java =================================================================== --- apache-tomcat-9.0.36-src.orig/test/org/apache/catalina/realm/TestJNDIRealmIntegration.java +++ apache-tomcat-9.0.36-src/test/org/apache/catalina/realm/TestJNDIRealmIntegration.java @@ -56,26 +56,33 @@ public class TestJNDIRealmIntegration { @Parameterized.Parameters(name = "{index}: user[{5}], pwd[{6}]") public static Collection<Object[]> parameters() { List<Object[]> parameterSets = new ArrayList<>(); - for (String roleSearch : new String[] { ROLE_SEARCH_A, ROLE_SEARCH_B, ROLE_SEARCH_C }) { - addUsers(USER_PATTERN, null, null, roleSearch, ROLE_BASE, parameterSets); - addUsers(null, USER_SEARCH, USER_BASE, roleSearch, ROLE_BASE, parameterSets); + for (String userRoleAttribute : new String[] { "cn", null }) { + for (String roleSearch : new String[] { ROLE_SEARCH_A, ROLE_SEARCH_B, ROLE_SEARCH_C }) { + if (userRoleAttribute != null) { + addUsers(USER_PATTERN, null, null, roleSearch, ROLE_BASE, userRoleAttribute, parameterSets); + addUsers(null, USER_SEARCH, USER_BASE, roleSearch, ROLE_BASE, userRoleAttribute, parameterSets); + } + } + parameterSets.add(new Object[] { "cn={0},ou=s\\;ub,ou=people,dc=example,dc=com", null, null, ROLE_SEARCH_A, + "{3},ou=people,dc=example,dc=com", "testsub", "test", new String[] { "TestGroup4" }, + userRoleAttribute }); } - parameterSets.add(new Object[] { "cn={0},ou=s\\;ub,ou=people,dc=example,dc=com", null, null, ROLE_SEARCH_A, - "{3},ou=people,dc=example,dc=com", "testsub", "test", new String[] {"TestGroup4"} }); return parameterSets; } private static void addUsers(String userPattern, String userSearch, String userBase, String roleSearch, - String roleBase, List<Object[]> parameterSets) { + String roleBase, String userRoleAttribute, List<Object[]> parameterSets) { parameterSets.add(new Object[] { userPattern, userSearch, userBase, roleSearch, roleBase, - "test", "test", new String[] {"TestGroup"} }); + "test", "test", new String[] {"TestGroup"}, userRoleAttribute }); parameterSets.add(new Object[] { userPattern, userSearch, userBase, roleSearch, roleBase, - "t;", "test", new String[] {"TestGroup"} }); + "t;", "test", new String[] {"TestGroup"}, userRoleAttribute }); parameterSets.add(new Object[] { userPattern, userSearch, userBase, roleSearch, roleBase, - "t*", "test", new String[] {"TestGroup"} }); + "t*", "test", new String[] {"TestGroup"}, userRoleAttribute }); parameterSets.add(new Object[] { userPattern, userSearch, userBase, roleSearch, roleBase, - "t=", "test", new String[] {"Test<Group*2", "Test>Group*3"} }); + "t=", "test", new String[] {"Test<Group*2", "Test>Group*3"}, userRoleAttribute }); + parameterSets.add(new Object[] { userPattern, userSearch, userBase, roleSearch, roleBase, + "norole", "test", new String[0], userRoleAttribute }); } @@ -95,6 +102,8 @@ public class TestJNDIRealmIntegration { public String credentials; @Parameter(7) public String[] groups; + @Parameter(8) + public String realmConfigUserRoleAttribute; @Test public void testAuthenication() throws Exception { @@ -105,7 +114,7 @@ public class TestJNDIRealmIntegration { realm.setUserPattern(realmConfigUserPattern); realm.setUserSearch(realmConfigUserSearch); realm.setUserBase(realmConfigUserBase); - realm.setUserRoleAttribute("cn"); + realm.setUserRoleAttribute(realmConfigUserRoleAttribute); realm.setRoleName("cn"); realm.setRoleBase(realmConfigRoleBase); realm.setRoleSearch(realmConfigRoleSearch); @@ -197,6 +206,17 @@ public class TestJNDIRealmIntegration { result = conn.processOperation(addUserTestEquals); Assert.assertEquals(ResultCode.SUCCESS, result.getResultCode()); + AddRequest addUserNoRole = new AddRequest( + "dn: cn=norole,ou=people,dc=example,dc=com", + "objectClass: top", + "objectClass: person", + "objectClass: organizationalPerson", + "cn: norole", + "sn: No Role", + "userPassword: test"); + result = conn.processOperation(addUserNoRole); + Assert.assertEquals(ResultCode.SUCCESS, result.getResultCode()); + AddRequest addGroupTest = new AddRequest( "dn: cn=TestGroup,ou=people,dc=example,dc=com", "objectClass: top", Index: apache-tomcat-9.0.36-src/webapps/docs/changelog.xml =================================================================== --- apache-tomcat-9.0.36-src.orig/webapps/docs/changelog.xml +++ apache-tomcat-9.0.36-src/webapps/docs/changelog.xml @@ -48,6 +48,10 @@ <subsection name="Catalina"> <changelog> <fix> + <bug>63508</bug>: NPE in JNDIRealm when no <code>userRoleAttribute</code> + is given. (fschumacher) + </fix> + <fix> <bug>64432</bug>: Correct a refactoring regression that broke handling of multi-line configuration in the RewriteValve. Patch provided by Jj. (markt)
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor