Skip to content

Commit 8ca6451

Browse files
committed
Fixed length bug in putString (Fixes #187)
1 parent 5e1be8b commit 8ca6451

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

src/main/java/net/schmizz/sshj/common/Buffer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ public T putBytes(byte[] b) {
246246
* @return this
247247
*/
248248
public T putBytes(byte[] b, int off, int len) {
249-
return putUInt32(len - off).putRawBytes(b, off, len);
249+
return putUInt32(len).putRawBytes(b, off, len);
250250
}
251251

252252
public void readRawBytes(byte[] buf)

src/main/java/net/schmizz/sshj/sftp/RemoteFile.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ protected Promise<Response, SFTPException> asyncWrite(long fileOffset, byte[] da
8282
throws IOException {
8383
return requester.request(newRequest(PacketType.WRITE)
8484
.putUInt64(fileOffset)
85-
// TODO The SFTP spec claims this field is unneeded...? See #187
86-
.putUInt32(len)
87-
.putRawBytes(data, off, len)
85+
.putString(data, off, len)
8886
);
8987
}
9088

0 commit comments

Comments
 (0)