Skip to content

Commit

Permalink
nassh: improved sftp init response check logic
Browse files Browse the repository at this point in the history
Change-Id: Iddfd2a43398b3d22fcb3e15c380f10f9d34f1058
Reviewed-on: https://chromium-review.googlesource.com/439906
Reviewed-by: Rob Ginda <[email protected]>
Tested-by: Mitchell McDermott <[email protected]>
  • Loading branch information
Mitchell McDermott committed Feb 10, 2017
1 parent 518303b commit 0430a98
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions nassh/js/nassh_command_instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -1016,10 +1016,11 @@ nassh.CommandInstance.prototype.onPlugin_.write = function(fd, data) {
*/
function isSftpInitResponse(data) {
var packet = new nassh.sftp.Packet(atob(data));
var byteArray = packet.toByteArray();
var packetLength = packet.getUint32();
var packetType = packet.getUint8();

// returns true if the packet has a valid length and is of type VERSION (2).
return byteArray[3] == byteArray.length - 4 && byteArray[4] == 2;
return packetLength == packet.getLength() - 4 && packetType == 2;
}

/**
Expand Down

0 comments on commit 0430a98

Please sign in to comment.