Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f549391

Browse files
Add end of stream validation to handshake
1 parent 175b6de commit f549391

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

‎src/main/java/dev/gustavoavila/websocketclient/WebSocketClient.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -776,10 +776,20 @@ private void verifyServerHandshake(InputStream inputStream, String secWebSocketK
776776

777777
outer:do {
778778
inner:do {
779-
char c = (char) inputStream.read();
779+
int result = inputStream.read();
780+
if (result == -1) {
781+
throw new IOException("Unexpected end of stream");
782+
}
783+
784+
char c = (char) result;
780785
bytesRead++;
781786
if (c == '\r') {
782-
c = (char) inputStream.read();
787+
result = inputStream.read();
788+
if (result == -1) {
789+
throw new IOException("Unexpected end of stream");
790+
}
791+
792+
c = (char) result;
783793
bytesRead++;
784794
if (c == '\n') {
785795
if (lastLineBreak) {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /