Skip to content

Commit e8c353d

Browse files
committed
missing changes
1 parent e4315db commit e8c353d

File tree

20 files changed

+118
-655
lines changed

20 files changed

+118
-655
lines changed

channels.c

Lines changed: 81 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,85 +1722,95 @@ channel_handle_wfd(Channel *c, fd_set *readset, fd_set *writeset)
17221722
int len;
17231723

17241724
/* Send buffered output data to the socket. */
1725-
if (c->wfd != -1 &&
1726-
FD_ISSET(c->wfd, writeset) &&
1727-
buffer_len(&c->output) > 0) {
1728-
olen = buffer_len(&c->output);
1729-
if (c->output_filter != NULL) {
1730-
if ((buf = c->output_filter(c, &data, &dlen)) == NULL) {
1731-
debug2("channel %d: filter stops", c->self);
1732-
if (c->type != SSH_CHANNEL_OPEN)
1733-
chan_mark_dead(c);
1734-
else
1735-
chan_write_failed(c);
1736-
return -1;
1737-
}
1738-
} else if (c->datagram) {
1739-
buf = data = buffer_get_string(&c->output, &dlen);
1740-
} else {
1741-
buf = data = buffer_ptr(&c->output);
1742-
dlen = buffer_len(&c->output);
1743-
}
1725+
if (c->wfd != -1 &&
1726+
FD_ISSET(c->wfd, writeset) &&
1727+
buffer_len(&c->output) > 0) {
1728+
olen = buffer_len(&c->output);
1729+
if (c->output_filter != NULL) {
1730+
if ((buf = c->output_filter(c, &data, &dlen)) == NULL) {
1731+
debug2("channel %d: filter stops", c->self);
1732+
if (c->type != SSH_CHANNEL_OPEN)
1733+
chan_mark_dead(c);
1734+
else
1735+
chan_write_failed(c);
1736+
return -1;
1737+
}
1738+
}
1739+
else if (c->datagram) {
1740+
buf = data = buffer_get_string(&c->output, &dlen);
1741+
}
1742+
else {
1743+
buf = data = buffer_ptr(&c->output);
1744+
dlen = buffer_len(&c->output);
1745+
}
17441746

1745-
if (c->datagram) {
1746-
/* ignore truncated writes, datagrams might get lost */
1747-
len = write(c->wfd, buf, dlen);
1748-
free(data);
1749-
if (len < 0 && (errno == EINTR || errno == EAGAIN ||
1750-
errno == EWOULDBLOCK))
1751-
return 1;
1752-
if (len <= 0) {
1753-
if (c->type != SSH_CHANNEL_OPEN)
1754-
chan_mark_dead(c);
1755-
else
1756-
chan_write_failed(c);
1757-
return -1;
1758-
}
1759-
goto out;
1760-
}
1747+
if (c->datagram) {
1748+
/* ignore truncated writes, datagrams might get lost */
1749+
len = write(c->wfd, buf, dlen);
1750+
free(data);
1751+
if (len < 0 && (errno == EINTR || errno == EAGAIN ||
1752+
errno == EWOULDBLOCK))
1753+
return 1;
1754+
if (len <= 0) {
1755+
if (c->type != SSH_CHANNEL_OPEN)
1756+
chan_mark_dead(c);
1757+
else
1758+
chan_write_failed(c);
1759+
return -1;
1760+
}
1761+
goto out;
1762+
}
17611763
#ifdef _AIX
1762-
/* XXX: Later AIX versions can't push as much data to tty */
1763-
if (compat20 && c->wfd_isatty)
1764-
dlen = MIN(dlen, 8*1024);
1764+
/* XXX: Later AIX versions can't push as much data to tty */
1765+
if (compat20 && c->wfd_isatty)
1766+
dlen = MIN(dlen, 8 * 1024);
1767+
#endif
1768+
#ifdef WIN32_FIXME /* TODO - Fix this - on windows we somehow end up with dlen = 0*/
1769+
if (dlen > 0) {
17651770
#endif
17661771

1767-
len = write(c->wfd, buf, dlen);
1768-
if (len < 0 &&
1769-
(errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK))
1770-
return 1;
1771-
if (len <= 0) {
1772-
if (c->type != SSH_CHANNEL_OPEN) {
1773-
debug2("channel %d: not open", c->self);
1774-
chan_mark_dead(c);
1775-
return -1;
1776-
} else if (compat13) {
1777-
buffer_clear(&c->output);
1778-
debug2("channel %d: input draining.", c->self);
1779-
c->type = SSH_CHANNEL_INPUT_DRAINING;
1780-
} else {
1781-
chan_write_failed(c);
1782-
}
1783-
return -1;
1784-
}
1772+
len = write(c->wfd, buf, dlen);
1773+
if (len < 0 &&
1774+
(errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK))
1775+
return 1;
1776+
if (len <= 0) {
1777+
if (c->type != SSH_CHANNEL_OPEN) {
1778+
debug2("channel %d: not open", c->self);
1779+
chan_mark_dead(c);
1780+
return -1;
1781+
}
1782+
else if (compat13) {
1783+
buffer_clear(&c->output);
1784+
debug2("channel %d: input draining.", c->self);
1785+
c->type = SSH_CHANNEL_INPUT_DRAINING;
1786+
}
1787+
else {
1788+
chan_write_failed(c);
1789+
}
1790+
return -1;
1791+
}
17851792
#ifndef WIN32_FIXME//R
17861793
#ifndef BROKEN_TCGETATTR_ICANON
1787-
if (compat20 && c->isatty && dlen >= 1 && buf[0] != '\r') {
1788-
if (tcgetattr(c->wfd, &tio) == 0 &&
1789-
!(tio.c_lflag & ECHO) && (tio.c_lflag & ICANON)) {
1790-
/*
1791-
* Simulate echo to reduce the impact of
1792-
* traffic analysis. We need to match the
1793-
* size of a SSH2_MSG_CHANNEL_DATA message
1794-
* (4 byte channel id + buf)
1795-
*/
1796-
packet_send_ignore(4 + len);
1797-
packet_send();
1798-
}
1799-
}
1794+
if (compat20 && c->isatty && dlen >= 1 && buf[0] != '\r') {
1795+
if (tcgetattr(c->wfd, &tio) == 0 &&
1796+
!(tio.c_lflag & ECHO) && (tio.c_lflag & ICANON)) {
1797+
/*
1798+
* Simulate echo to reduce the impact of
1799+
* traffic analysis. We need to match the
1800+
* size of a SSH2_MSG_CHANNEL_DATA message
1801+
* (4 byte channel id + buf)
1802+
*/
1803+
packet_send_ignore(4 + len);
1804+
packet_send();
1805+
}
1806+
}
18001807
#endif
18011808
#endif
1802-
buffer_consume(&c->output, len);
1803-
}
1809+
buffer_consume(&c->output, len);
1810+
}
1811+
#ifdef WIN32_FIXME /* for if (dlen > 0) */
1812+
}
1813+
#endif
18041814
out:
18051815
if (compat20 && olen > 0)
18061816
c->local_consumed += olen - buffer_len(&c->output);

contrib/win32/openssh/config.h.vs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1671,6 +1671,7 @@
16711671
#define HAVE_KRB5_FREE_ERROR_MESSAGE 1
16721672
#define HAVE_DECL_NFDBITS 0
16731673
#define HAVE_DECL_HOWMANY 0
1674+
#define HAVE_DES_CRYPT 1
16741675

16751676
#define WIN32_ZLIB_NO 1
16761677
#define USE_MSCNG 1

contrib/win32/openssh/win32compat.vcxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@
151151
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\gettimeofday.c" />
152152
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\homedirhelp.c" />
153153
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\kerberos.c" />
154-
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\lsalogon.c" />
155-
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\lsastring.c" />
156154
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\pwd.c" />
157155
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\startupneeds.c" />
158156
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\strcasecmp.c" />

contrib/win32/openssh/win32compat.vcxproj.filters

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,6 @@
5757
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\kerberos.c">
5858
<Filter>Source Files</Filter>
5959
</ClCompile>
60-
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\lsalogon.c">
61-
<Filter>Source Files</Filter>
62-
</ClCompile>
63-
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\lsastring.c">
64-
<Filter>Source Files</Filter>
65-
</ClCompile>
6660
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\pwd.c">
6761
<Filter>Source Files</Filter>
6862
</ClCompile>

contrib/win32/win32compat/inc/defs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ typedef int sigset_t;
7070

7171
typedef unsigned short _mode_t;
7272
typedef _mode_t mode_t;
73-
typedef int pid_t;
73+
typedef DWORD_PTR pid_t;
7474

7575
/* wait pid options */
7676
#define WNOHANG 1

contrib/win32/win32compat/inc/sys/socket.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919
#define recv(a,b,c,d) w32_recv((a), (b), (c), (d))
2020
#define send(a,b,c,d) w32_send((a), (b), (c), (d))
2121
#define shutdown(a,b) w32_shutdown((a), (b))
22-
#define socketpair(a,b,c) w32_socketpair((a), (b), (c))
22+
#define socketpair(a,b,c,d) w32_socketpair((a), (b), (c), (d))

contrib/win32/win32compat/inc/unistd.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
/* Compatibility header to avoid lots of #ifdefs in includes.h on Win32 */
3939

4040
#include <conio.h>
41-
#include <direct.h>
4241

4342
/* We can't put these in string.h since we can't easily override that header, so here they are */
4443
#if !defined(HAVE_STRCASECMP) && !defined(__MINGW32__)

contrib/win32/win32compat/inc/w32posix.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,17 @@ int w32_connect(int fd, const struct sockaddr* name, int namelen);
3232
int w32_recv(int fd, void *buf, size_t len, int flags);
3333
int w32_send(int fd, const void *buf, size_t len, int flags);
3434
int w32_shutdown(int fd, int how);
35-
int w32_socketpair(int domain, int type, int sv[2]);
35+
int w32_socketpair(int domain, int type, int protocol, int sv[2]);
3636

3737
/*non-network (file) i/o*/
38+
#undef fdopen
3839
#define fdopen(a,b) w32_fdopen((a), (b))
3940
#define fstat(a,b) w32_fstat((a), (b))
4041

4142
struct w32_stat;
4243
int w32_pipe(int *pfds);
4344
int w32_open(const char *pathname, int flags, ...);
44-
int w32_read(int fd, void *dst, unsigned int max);
45+
int w32_read(int fd, void *dst, size_t max);
4546
int w32_write(int fd, const void *buf, unsigned int max);
4647
int w32_fstat(int fd, struct w32_stat *buf);
4748
int w32_stat(const char *path, struct w32_stat *buf);

contrib/win32/win32compat/includes/pwd.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ struct passwd *getpwuid(uid_t uid);
2626
struct passwd *getpwnam(const char *username);
2727
void endpwent(void);
2828

29-
typedef int PWD_USER_TOKEN; /* This is really just a HANDLE, but we might not have windows.h included */
30-
PWD_USER_TOKEN PwdCreateUserToken(const char *pUserName, const char *pDomainName, const char *pSourceName);
29+
char *realpathWin32(const char *path, char resolved[PATH_MAX]);
3130

3231
const char *
3332
user_from_uid(uid_t uid, int nouser);

contrib/win32/win32compat/lsa/Ssh-lsa.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,15 @@ void LsaFreeUnicodeString(PUNICODE_STRING lsaStr)
9696
NTSTATUS FillUnicodeString(UNICODE_STRING *lsaStr, const Char *str)
9797
{
9898
NTSTATUS ntStat = STATUS_NO_MEMORY;
99-
USHORT cbSize = 0;
100-
FAIL(lsaStr == NULL);
99+
size_t cbSize = 0;
100+
FAIL(lsaStr == NULL);
101101
FAIL(lsaStr->Buffer == NULL);
102102
FAIL(str == NULL);
103103
cbSize = strlen(str);
104104
FAIL(cbSize >= lsaStr->MaximumLength);
105105
_swprintf(lsaStr->Buffer, L"%hs", str);
106-
lsaStr->Length = cbSize * 2;
107-
lsaStr->Buffer[cbSize * 2] = 0x0000;
106+
lsaStr->Length = (USHORT)(cbSize * 2);
107+
lsaStr->Buffer[cbSize * 2] = 0x0000;
108108
ntStat = STATUS_SUCCESS;
109109

110110
fail:

0 commit comments

Comments
 (0)