Skip to content

Commit 3774c3a

Browse files
committed
Fix SendAppData OOB when ofst > 0
1 parent 162cf78 commit 3774c3a

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/java/com/wolfssl/provider/jsse/WolfSSLEngine.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -743,8 +743,8 @@ private synchronized int SendAppData(ByteBuffer[] in, int ofst, int len)
743743
/* Get total input data size, store input array positions */
744744
for (i = ofst; i < ofst + len; i++) {
745745
totalIn += in[i].remaining();
746-
pos[i] = in[i].position();
747-
limit[i] = in[i].limit();
746+
pos[i - ofst] = in[i].position();
747+
limit[i - ofst] = in[i].limit();
748748
}
749749

750750
/* Allocate static buffer for application data, clear before use */
@@ -766,7 +766,7 @@ private synchronized int SendAppData(ByteBuffer[] in, int ofst, int len)
766766
in[i].limit(in[i].position() + bufChunk); /* set limit */
767767
this.staticAppDataBuf.put(in[i]); /* get data */
768768
inputLeft -= bufChunk;
769-
in[i].limit(limit[i]); /* reset limit */
769+
in[i].limit(limit[i - ofst]); /* reset limit */
770770

771771
if (inputLeft == 0) {
772772
break; /* reached data size needed, stop reading */
@@ -787,7 +787,7 @@ private synchronized int SendAppData(ByteBuffer[] in, int ofst, int len)
787787
if (ret <= 0) {
788788
/* error, reset in[] positions for next call */
789789
for (i = ofst; i < ofst + len; i++) {
790-
in[i].position(pos[i]);
790+
in[i].position(pos[i - ofst]);
791791
}
792792
}
793793

0 commit comments

Comments
 (0)