Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ dist
build
*~
*.so
.idea/
7 changes: 6 additions & 1 deletion ssh2/sftp_handle.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,12 @@ cdef class SFTPHandle:
cdef char *cbuf = buf
cdef ssize_t rc
with nogil:
rc = c_sftp.libssh2_sftp_write(self._handle, cbuf, _size)
while _size > 0:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this change if _size is 0 rc will be undefined and will cause a crash. Can skip call to write and just return 0 in that case.

rc = c_sftp.libssh2_sftp_write(self._handle, cbuf, _size)
if rc < 0:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you elaborate on this? why not?
Would think that you would keep writing the content of 'cbuf' until it is empty

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My mistake actually :)

break
cbuf += rc
_size -= rc
return handle_error_codes(rc)

IF EMBEDDED_LIB:
Expand Down