diff --git a/uppsrc/Core/SSH/Channels.cpp b/uppsrc/Core/SSH/Channels.cpp index 28a6904c7..a06d305cb 100644 --- a/uppsrc/Core/SSH/Channels.cpp +++ b/uppsrc/Core/SSH/Channels.cpp @@ -268,7 +268,10 @@ int SshChannel::Read(void *ptr, int size, int sid) { int sz = min(size - done, ssh->chunk_size); - int rc = libssh2_channel_read_ex(*channel, sid, (char*) ptr + done, sz); + int rc = static_cast( + libssh2_channel_read_ex(*channel, sid, (char*) ptr + done, size_t(sz)) + ); + if(rc < 0 && !WouldBlock(rc)) SetError(rc); if(rc > 0) { @@ -290,7 +293,10 @@ int SshChannel::Write(const void *ptr, int size, int sid) { int sz = min(size - done, ssh->chunk_size); - int rc = libssh2_channel_write_ex(*channel, sid, (const char*) ptr + done, sz); + int rc = static_cast( + libssh2_channel_write_ex(*channel, sid, (const char*) ptr + done, size_t(sz)) + ); + if(!WouldBlock(rc) && rc < 0) SetError(rc); if(rc > 0) { diff --git a/uppsrc/Core/SSH/SFtp.cpp b/uppsrc/Core/SSH/SFtp.cpp index 3e9cb3945..0b34eb892 100644 --- a/uppsrc/Core/SSH/SFtp.cpp +++ b/uppsrc/Core/SSH/SFtp.cpp @@ -135,7 +135,10 @@ int SFtp::Read(SFtpHandle handle, void* ptr, int size) { int sz = min(size - done, ssh->chunk_size); - int rc = libssh2_sftp_read(handle, (char*) ptr + done, sz); + int rc = static_cast( + libssh2_sftp_read(handle, (char*) ptr + done, size_t(sz)) + ); + if(!WouldBlock(rc) && rc < 0) SetError(rc); if(rc > 0) { @@ -152,7 +155,10 @@ int SFtp::Write(SFtpHandle handle, const void* ptr, int size) { int sz = min(size - done, ssh->chunk_size); - int rc = libssh2_sftp_write(handle, (const char*) ptr + done, sz); + int rc = static_cast( + libssh2_sftp_write(handle, (const char*) ptr + done, size_t(sz)) + ); + if(!WouldBlock(rc) && rc < 0) SetError(rc); if(rc > 0) { diff --git a/uppsrc/Core/SSH/Scp.cpp b/uppsrc/Core/SSH/Scp.cpp index 5e8cd0dfb..e991f3f5a 100644 --- a/uppsrc/Core/SSH/Scp.cpp +++ b/uppsrc/Core/SSH/Scp.cpp @@ -57,7 +57,7 @@ bool Scp::Load(Stream& s, ScpAttrs a, int64 maxsize) done_ += n; s.Put(chunk, n); if((nowait = WhenProgress(done_, size))) { - msg = "File transfer aborted."; + msg = "File transfer is aborted."; break; } } @@ -82,7 +82,7 @@ bool Scp::Save(Stream& s) if(n < l) s.Seek(n); if((nowait = WhenProgress(done_, size))) { - msg = "File transfer aborted.";; + msg = "File transfer is aborted.";; break; } } diff --git a/uppsrc/Core/SSH/Shell.cpp b/uppsrc/Core/SSH/Shell.cpp index bd0c111df..8c17044bd 100644 --- a/uppsrc/Core/SSH/Shell.cpp +++ b/uppsrc/Core/SSH/Shell.cpp @@ -158,7 +158,7 @@ void SshShell::ConsoleRead() if(!EventWait(STDIN_FILENO, WAIT_READ, 0)) return; Buffer buffer(ssh->chunk_size); - auto n = read(STDIN_FILENO, buffer, ssh->chunk_size); + auto n = read(STDIN_FILENO, buffer, size_t(ssh->chunk_size)); if(n > 0) Send(String(buffer, n)); else @@ -170,7 +170,7 @@ void SshShell::ConsoleWrite(const void* buffer, int len) { if(!EventWait(STDOUT_FILENO, WAIT_WRITE, 0)) return; - auto n = write(STDOUT_FILENO, buffer, len); + auto n = write(STDOUT_FILENO, buffer, size_t(len)); if(n == -1 && errno != EAGAIN) SetError(-1, "Couldn't write output to console."); } @@ -287,16 +287,20 @@ void SshShell::X11Loop() SOCKET sock = xrequests[i].b; if(EventWait(sock, WAIT_WRITE, 0)) { - int rc = libssh2_channel_read(xhandle, xbuffer, xbuflen); + int rc = static_cast( + libssh2_channel_read(xhandle, xbuffer, size_t(xbuflen)) + ); if(!WouldBlock(rc) && rc < 0) SetError(-1, "[X11]: Read failed."); if(rc > 0) write(sock, xbuffer, rc); } if(EventWait(sock, WAIT_READ, 0)) { - int rc = read(sock, xbuffer, xbuflen); + int rc = static_cast( + read(sock, xbuffer, size_t(xbuflen)) + ); if(rc > 0) - libssh2_channel_write(xhandle, (const char*) xbuffer, rc); + libssh2_channel_write(xhandle, (const char*) xbuffer, size_t(rc)); } if(libssh2_channel_eof(xhandle) == 1) { LLOG("[X11] EOF received.");