Skip to content

Commit 6fdbb05

Browse files
rafapraxbrianchandotcom
authored andcommitted
LPD-43475 Avoid IndexOutOfBoundsException when the encrypted p******d does not have the algorithm prefixed
1 parent 45c3ca7 commit 6fdbb05

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

portal-kernel/src/com/liferay/portal/kernel/security/pwd/PasswordEncryptor.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,13 @@ public String encrypt(
5454
public default String getEncryptedPasswordAlgorithmSettings(
5555
String encryptedPassword) {
5656

57-
return encryptedPassword.substring(
58-
1, encryptedPassword.indexOf(CharPool.CLOSE_CURLY_BRACE));
57+
int index = encryptedPassword.indexOf(CharPool.CLOSE_CURLY_BRACE);
58+
59+
if (index < 0) {
60+
return null;
61+
}
62+
63+
return encryptedPassword.substring(1, index);
5964
}
6065

6166
}

0 commit comments

Comments
 (0)