Skip to content

Commit 3f71c81

Browse files
committed
sftp-server.exe put now works
Fixed sftp-server put verb not working. Tested from out sftp client and linux fedora openssh 6.9p1 sftp clients in transferring small and large files using both get and put verbs.
1 parent 6b70a28 commit 3f71c81

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

sftp-server.c

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,6 +1730,10 @@ process_extended(u_int32_t id)
17301730

17311731
/* stolen from ssh-agent */
17321732

1733+
#ifdef WIN32_FIXME
1734+
int readsomemore=0;
1735+
#endif
1736+
17331737
static void
17341738
process(void)
17351739
{
@@ -1741,18 +1745,31 @@ process(void)
17411745
int i, r;
17421746
u_int32_t id;
17431747

1748+
#ifdef WIN32_FIXME
1749+
// we use to tell our caller to read more data if a message is not complete
1750+
readsomemore=0;
1751+
#endif
1752+
17441753
buf_len = sshbuf_len(iqueue);
1745-
if (buf_len < 5)
1754+
if (buf_len < 5) {
1755+
#ifdef WIN32_FIXME
1756+
readsomemore =1;
1757+
#endif
17461758
return; /* Incomplete message. */
1759+
}
17471760
cp = sshbuf_ptr(iqueue);
17481761
msg_len = get_u32(cp);
17491762
if (msg_len > SFTP_MAX_MSG_LENGTH) {
17501763
error("bad message from %s local user %s",
17511764
client_addr, pw->pw_name);
17521765
sftp_server_cleanup_exit(11);
17531766
}
1754-
if (buf_len < msg_len + 4)
1767+
if (buf_len < msg_len + 4) {
1768+
#ifdef WIN32_FIXME
1769+
readsomemore =1;
1770+
#endif
17551771
return;
1772+
}
17561773
if ((r = sshbuf_consume(iqueue, 4)) != 0)
17571774
fatal("%s: buffer error: %s", __func__, ssh_err(r));
17581775
buf_len -= 4;
@@ -1834,9 +1851,13 @@ sftp_server_usage(void)
18341851
#ifdef WIN32_FIXME
18351852
DWORD select_in_handle( HANDLE in_handle)
18361853
{
1837-
DWORD bytesavail = 0 ;
1838-
//rc = WaitForSingleObject (in_handle, 0);
1854+
//DWORD rc = WaitForSingleObject (in_handle, 0);
1855+
//if (rc == WAIT_OBJECT_0)
1856+
// return 1;
1857+
//else
1858+
// return 0;
18391859

1860+
DWORD bytesavail = 0 ;
18401861
PeekNamedPipe(in_handle, NULL,0, NULL, &bytesavail, NULL );
18411862
return bytesavail;
18421863
}
@@ -2098,7 +2119,7 @@ sftp_server_main(int argc, char **argv, struct passwd *user_pw)
20982119

20992120
/* copy stdin to iqueue */
21002121
if ( select_read ) {
2101-
if ( select_in_handle(in_handle) || ( sshbuf_len(iqueue) <= 0)) {
2122+
if ( readsomemore || ( sshbuf_len(iqueue) <= 0)) {
21022123
len = _read(in, buf, sizeof buf);
21032124
if (len == 0) {
21042125
debug("read eof");

0 commit comments

Comments
 (0)