Skip to content

Commit 2821036

Browse files
committed
Safe comparison of username:password separator position against full string length
1 parent 0e98525 commit 2821036

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

OCPP-J/src/main/java/eu/chargetime/ocpp/WebSocketListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public ServerHandshakeBuilder onWebsocketHandshakeReceivedAsServer(WebSocket web
137137
for (int i = 0; i < credDecoded.length; i++) {
138138
if (credDecoded[i] == ':') {
139139
username = new String(Arrays.copyOfRange(credDecoded, 0, i), StandardCharsets.UTF_8);
140-
if (i != credDecoded.length - 1) {
140+
if (i + 1 < credDecoded.length) {
141141
password = Arrays.copyOfRange(credDecoded, i + 1, credDecoded.length);
142142
}
143143
break;

0 commit comments

Comments
 (0)