Skip to content

Commit 07bc523

Browse files
author
Anthony Scarpino
committed
8334670: SSLSocketOutputRecord buffer miscalculation
Reviewed-by: djelinski, ssahoo
1 parent 4ebb771 commit 07bc523

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/java.base/share/classes/sun/security/ssl/SSLSocketOutputRecord.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -168,12 +168,12 @@ void encodeHandshake(byte[] source,
168168

169169
for (int limit = (offset + length); offset < limit;) {
170170

171-
int remains = (limit - offset) + (count - position);
172-
int fragLen = Math.min(fragLimit, remains);
171+
int remains = (limit - offset);
172+
int fragLen = Math.min(fragLimit - count + position, remains);
173173

174174
// use the buf of ByteArrayOutputStream
175175
write(source, offset, fragLen);
176-
if (remains < fragLimit) {
176+
if (remains < fragLen) {
177177
return;
178178
}
179179

0 commit comments

Comments
 (0)