Skip to content

Commit

Permalink
Fixed length bug in putString (Fixes #187)
Browse files Browse the repository at this point in the history
  • Loading branch information
hierynomus committed Dec 27, 2017
1 parent 5e1be8b commit 8ca6451
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/java/net/schmizz/sshj/common/Buffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public T putBytes(byte[] b) {
* @return this
*/
public T putBytes(byte[] b, int off, int len) {
return putUInt32(len - off).putRawBytes(b, off, len);
return putUInt32(len).putRawBytes(b, off, len);
}

public void readRawBytes(byte[] buf)
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/net/schmizz/sshj/sftp/RemoteFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ protected Promise<Response, SFTPException> asyncWrite(long fileOffset, byte[] da
throws IOException {
return requester.request(newRequest(PacketType.WRITE)
.putUInt64(fileOffset)
// TODO The SFTP spec claims this field is unneeded...? See #187
.putUInt32(len)
.putRawBytes(data, off, len)
.putString(data, off, len)
);
}

Expand Down

0 comments on commit 8ca6451

Please sign in to comment.