1
0
mirror of https://github.com/winscp/winscp.git synced 2026-10-24 02:28:55 +03:00

172 Commits

Author SHA1 Message Date
Eduardo C.
a8fc40bd0e Portability: let core build with clang on Linux and Windows (#79)
* Cast between closure types with a functional cast, not reinterpret_cast

A Borland __closure is a built-in (code, data) pair, so reinterpret_cast
between two closure types is allowed. Under standard C++ a closure is a
class, and reinterpret_cast cannot convert one class object into another.
The functional cast is the old C-style cast this line had before
"Refactoring old-style casts" (e5efed895), so C++Builder compiles it as it
did then, and a compiler implementing closures as classes can give it the
same meaning.

* Read the knocked FTP port's IPv4 address as 32 bits

The address is read through an unsigned long pointer. That is 32 bits on
Windows (LLP64), so it reads exactly the four address bytes there; on LP64
targets unsigned long is 64 bits, and the read runs four bytes past the
address into whatever follows it in gethostbyname's buffer. The assignment
to the 32-bit s_addr then keeps the right bytes on little-endian machines,
which is why it goes unnoticed, but the over-read is undefined. ULONG is 32
bits on every Windows compiler, as Windows API layers for POSIX define it
too.

* Compile the synchronize checklist's Explorer file operation on Windows only

TSynchronizeChecklistFileOperation carries out a synchronization checklist
through Explorer's IFileOperation (a Shell COM object), so that local
deletions go to the recycle bin with Explorer's progress and undo. Only
WinSCP's Windows GUI uses it (CustomScpExplorer.cpp). Elsewhere neither the
object nor the interfaces exist, and declaring them only to compile would
pretend to a facility that is not there; a frontend on another platform
implements the operation its own way. The class and its implementation are
guarded with _WIN32, which C++Builder defines, so the Windows build is
unchanged.

* Declare the SIOCATMARK result as ULONG, the type p_ioctlsocket takes

network.c declares ioctlsocket as taking ULONG * (its DECL_WINDOWS_FUNCTION)
but passes a u_long. Both are 32 bits on Windows, so the two agree there. On
an LP64 platform u_long is 64 bits and ULONG 32, so the pointer types differ
and the callee would write half the variable. ULONG is what the declaration
says, and is the same type on Windows.

* Pick aes-ni.c's _mm_setr_epi8 for any GCC-compatible compiler

MM_SETR_EPI8 uses _mm_setr_epi8 only under _WIN64, falling back to a brace
initialiser that is correct for MSVC's __m128i (a byte union) but fills
clang's and GCC's (a two-lane vector) wrongly; the _WIN64 condition fixed
that for Win64 builds only. Any compiler defining __GNUC__ (clang does) now
takes the intrinsic.

* Compile WinSCP's Windows-only additions to neon on Windows only

WinSCP builds neon for Win32 alone, and three of its additions assume it:
ne_openssl.c includes <windows.h> (it uses nothing from it), timed_connect
switches the socket to non-blocking mode with Winsock's ioctlsocket instead
of upstream's fcntl, and ne_sock_sspi_init calls into SSPI unconditionally.
On POSIX neon uses BSD sockets directly, so the include is guarded with
_WIN32, the two ioctlsocket branches are taken only on _WIN32 (upstream's
fcntl code beside them is used otherwise), and ne_sock_sspi_init calls SSPI
under HAVE_SSPI, as ne_sock_init's own call does, reporting failure (-1)
without it -- which WebDAVFileSystem.cpp already handles as SSPI being
unavailable. C++Builder defines _WIN32 and neon's Win32 config.h defines
HAVE_SSPI, so the Windows build is unchanged.

* Use in_addr's s_addr in FileZilla's proxy layer

AsyncProxySocketLayer.cpp reaches the IPv4 address through Winsock's union,
sin_addr.S_un.S_addr. Winsock also defines s_addr as exactly that member
(#define s_addr S_un.S_addr), and s_addr is the name BSD sockets and POSIX
give the field; a POSIX in_addr has no S_un. Same field, so the Windows
build is unchanged.

* Pass FileZilla's two tool strings as UnicodeString, not std::wstring

CFileZillaTools::GetClientString and CustomReason return std::wstring; the
rest of the interface between core and FileZilla, and both sides' own code,
use UnicodeString or wchar_t pointers. Built with a 2-byte wchar_t on a
platform whose C++ library assumes 4 (clang's -fshort-wchar on Linux),
std::wstring is unusable: libstdc++ provides basic_string<wchar_t> as a
precompiled extern template for its own wchar_t, and char_traits<wchar_t>
calls the C library's 4-byte wcslen and wmemcpy: a Linux build of
FtpFileSystem.cpp imported wcslen through it. The values are only built from
UnicodeString, compared with empty() and read with c_str(), so UnicodeString
is a direct replacement (IsEmpty for empty). On Windows, where wchar_t is 2
bytes throughout, behaviour is unchanged.

* Build storage key paths with backslashes on every platform

THierarchicalStorage joins registry and INI key paths (Sessions\My site)
through its IncludeTrailingBackslash and ExcludeTrailingBackslash members,
which defer to the RTL functions of those names. The RTL's add and strip the
platform's path delimiter: a backslash on Windows, a slash on POSIX, where
these functions also build local file paths. Keys are not file paths: their
separator is a backslash everywhere, and the INI file's sections say so. The
members now add and strip a backslash themselves; on Windows that is what
the RTL did, so the behaviour there is unchanged. Without this, on POSIX the
current key became "Sessions/", matched no section, and no stored site
loaded.

* Hand neon a copy of the TLS-init closure, not its two pointers

SetNeonTlsInit stores the closure in the neon session by reinterpreting it
as a TMethod and saving its code and data pointers, and ne_init_ssl_session
rebuilds it with MakeMethod. That relies on a closure being exactly those
two pointers, which only Borland's __closure is; with any other closure type
the saved words are its internals, read from a by-value parameter that is
gone by the time neon calls back, and the rebuilt closure is garbage (a
clang build's first WebDAV-over-TLS connection crashed there). The session
now holds a heap copy of the closure, freed by neon's destroy-session hook
-- which also covers the sessions libs3 creates and destroys itself -- and
ne_init_ssl_session calls that copy. On C++Builder the behaviour is the
same, at the cost of one small allocation per session.

* Take CString's search results as const wchar_t *

CString::Find, ReverseFind and FindOneOf search the const string c_str()
returns and keep the result in a wchar_t *. ISO C++ declares wcschr,
wcsrchr, wcsstr and wcspbrk on a const string as returning const wchar_t *,
as MSVC's and newer mingw-w64 headers (llvm-mingw's) do, so the
initialisation does not compile there. The pointers are only compared and
subtracted: const is all they need.

* Index the string a string-list property returns, not the property

GetLocales takes a character of Exts->Strings[Index]. Under clang the
__declspec(property) standing for TStrings::Strings' __property reads a
second subscript as the property's own second index, so the expression is a
two-argument call to the getter and does not compile (parentheses do not
change that). Read into a UnicodeString first, the second subscript indexes
the string the property returns, as under C++Builder.

---------

Co-authored-by: Eduardo Correia <ecorreia@apliant.com.br>
2026-10-20 16:01:54 +02:00
Eduardo C.
101189ca27 Translate old-format RSA host keys in retrieve_host_key (#75)
* Translate old-format RSA host keys in retrieve_host_key

retrieve_host_key comes from PuTTY's check_stored_host_key, where key is the
server's key and an old-format registry entry is translated and kept only if
it matches. In retrieve_host_key key is the output buffer, so the
translation is compared with whatever the caller's buffer holds (TSecureShell
passes an uninitialised one) and in practice never matches: an old-format
host key is reported as not cached.

The translation is now returned as the stored key, for the caller to compare
with the server's key, as it compares every other stored key. It is not
written back in the new format, as nothing here has verified it.

* Keep the original strbuf_to_str in retrieve_host_key's old-format path

Exclude only the comparison, the put_reg_sz and the else (#ifndef WINSCP),
so that it is clear the strbuf_to_str is what the original does when the
key matches.

---------

Co-authored-by: Eduardo Correia <ecorreia@apliant.com.br>
2026-10-16 11:47:21 +02:00
Eduardo Correia
be053db0a6 Forget the freed system directory in win_misc_cleanup
win_misc_cleanup frees get_system_dir's cached buffer but leaves the pointer
and its size, so a get_system_dir call after the cleanup returns freed
memory instead of fetching the directory again.
2026-10-13 11:13:14 +02:00
Martin Prikryl
0a91a3e4e3 Merge branch 'thirdparty'
# Conflicts:

#	source/putty/ssh/connection2.c

Source commit: 4413da04be2a27098da2488953e6e86301be66cd
2026-08-26 16:07:38 +02:00
Martin Prikryl
b3732d9b70 PuTTY 0.85
Source commit: c9fb0e3663609e43f0fc37e1e96e9f2177809f15
2026-08-26 16:06:53 +02:00
Martin Prikryl
cc81f2c3fc Updating code to PuTTY 0.84
Source commit: 71b0bdd5bb7ff22e916234fffeedf5db87668460
2026-05-30 01:07:44 +02:00
Martin Prikryl
4d24fdb881 Merge branch 'thirdparty_dev' into dev
# Conflicts:
#	source/putty/callback.c

#	source/putty/putty.h
#	source/putty/ssh/ssh.c
#	source/putty/windows/network.c
#	source/putty/windows/platform.h

Source commit: e4552f4c309c1e34fce155ecad0bfaf22cd8bcee
2026-05-30 01:04:55 +02:00
Martin Prikryl
fbc97830e9 PuTTY 0.84
Source commit: 74c128b1c46223d1ff41e055c5fadd44bf73dbe4
2026-05-30 01:01:18 +02:00
Martin Prikryl
d725f98ec4 Issue 618 – Experimental 64-bit version of WinSCP
https://winscp.net/tracker/618

Source commit: 329fb51d696db6c1d37d5c5240ff253af0df941b
2026-05-11 18:39:51 +02:00
Martin Prikryl
843729d656 Issue 1682 – Support OpenSSH ssh-agent
https://winscp.net/tracker/1682

Source commit: ec5961549076ee19737c0950b44216967609c51f
2026-02-25 01:22:31 +01:00
Martin Prikryl
115871701b There are no "missing braces" warnings afte f670f4eb + Solving some unused variables
Source commit: 06241c0127599e00d4ad3c60aa01a2cbff38ee74
2026-02-12 01:05:55 +01:00
Martin Prikryl
f670f4ebb1 Resetting differences to official PuTTY that are no longer needed
Most, if not all, were for compatibility with the classic C++Builder compiler (declarations in the middle of code + inline structure initializers)

Source commit: a9f38c3a07777e538c3c6e0fbdd38e9d68327dfa
2025-12-06 01:29:35 +01:00
Martin Prikryl
980db10682 Renaming files with "error" in name that triggers red highlight in IDE build log
Source commit: b31b9814c8e1956ba11a91f1b1312863da530992
2025-12-05 01:21:16 +01:00
Martin Prikryl
6963f08ffd Enabling all warnings in all projects and only selectively disabling those that are needed
with aim to eventually update the code to need as little warnings disabled as needed.

Some code updates (and even fixes) to avoid warning done already

Source commit: 5c45a6f56c52e7b0c5034ed9980cd65259a7372b
2025-12-04 01:16:16 +01:00
Martin Prikryl
23f7ce72d8 BCB11 has strtoumax
Source commit: 8f39df83ecbe435ec1c30cda1bedf1ccbe0eb773
2025-03-14 09:52:20 +01:00
Martin Prikryl
3f4e41fee0 Clang imposed changes that should be noop and have no effect on classic compiler
Mostly:
– incorrectly identified uninitialized variables
– explicit static global variables
– const, sign and down casts and safety
– typename use
– semicolon after function implementation
– unused variables, fields, arguments and macros
– field initialization order
– exact include filename case
– redundant in code macros already defined at project level

(cherry picked from commit f7f00c631e)

Source commit: 90ad9390853aba308abe73cf02e0281238c53c87
2025-03-13 16:46:26 +01:00
Martin Prikryl
8cd48fd0e5 Code errors identified by Clang
Notably:
Bug fix: Monospace font is not remembered if SSH banners are administratively forced
Change: Bug fix: In XML log, filename tag was included in stat tag, although explicitly documented not to

(cherry picked from commit 4019b56ffb)

Source commit: 8f8d10bc0c9f4ca626dceda1d3e9889dc22f4394
2025-03-13 06:42:18 +01:00
Martin Prikryl
85bddc2c5c Merge branch 'thirdparty_dev' into dev
Source commit: 4d92009391120144deb49f4cae233abae481b71f
2025-01-05 00:58:01 +01:00
Martin Prikryl
8459471bad PuTTY Pre-release 0.83:2025-01-03.1e45199
Source commit: 1675133a3ca89ff21576d3c554b83fcb225d73c3
2025-01-05 00:55:14 +01:00
Martin Prikryl
dd6b6bb399 Synchronizing set of PuTTY files on thirdparty and main branches
Source commit: 1c3e3c03392fb78531d4422438f6af8f8739880f
2024-12-28 00:54:41 +01:00
Martin Prikryl
2c16441f95 Bug fix: Failure when opening two SSH sessions at the same time
The primary cause was concurrent use of buffer-like MontyContext::scratch member.
But other non-thread-safe code was fixed along.

Found while implementing Issue 2318 which involves adding multiple queue items at the same moment

Source commit: f08842701165b662e475d249d0612a4404731a39
2024-12-21 01:19:41 +01:00
Martin Prikryl
25df2381f1 Updating code to PuTTY 0.82
Source commit: ddf59fef3b75f5efff8bf82fecdd61ef49970fd2
2024-12-05 16:51:39 +01:00
Martin Prikryl
a561deeac4 Merge branch 'thirdparty_dev' into dev
# Conflicts:
#	source/putty/crypto/ecc-ssh.c
#	source/putty/crypto/rsa.c

#	source/putty/errsock.c
#	source/putty/network.h
#	source/putty/proxy/proxy.c
#	source/putty/putty.h
#	source/putty/ssh/mainchan.c
#	source/putty/ssh/portfwd.c
#	source/putty/ssh/ssh.c
#	source/putty/sshpubk.c
#	source/putty/utils/conf.c
#	source/putty/utils/tempseat.c
#	source/putty/windows/gss.c
#	source/putty/windows/handle-socket.c
#	source/putty/windows/network.c
#	source/putty/windows/platform.h
#	source/putty/windows/storage.c
#	source/putty/windows/unicode.c
#	source/putty/windows/utils/filename.c

Source commit: bf2485b229a3855694c35c518f72482b97ca47c5
2024-12-05 14:59:26 +01:00
Martin Prikryl
6c12cb97d7 PuTTY 0.82 + Giving up on trying to not-link PuTTY unicode implementation
Source commit: 510b30d0a40b051c780d3d3e69b3b57cf4e25a05
2024-12-05 14:57:30 +01:00
Martin Prikryl
222decc2b2 Changes to PuTTY code that are not needed anymore
Possibly due to newer SDK in BCB11

Source commit: 68efec4dbd06c6bced1491db85a93d7bf399a25f
2024-11-21 00:54:42 +01:00
Martin Prikryl
a6adfa0ad3 Updating to PuTTY 0.80 – mostly Issue 2246 – Mitigations for SSH protocol "Terrapin" vulnerability
https://winscp.net/tracker/2246

Source commit: f7b34a47547af9b0b4bd32fb66d6d278c8b6b342
2023-12-20 13:48:13 +01:00
Martin Prikryl
a65773c31c Merge branch 'thirdparty_dev' into dev
Source commit: 70dad0f1516d5eba6d33587b07ece8d3aac4babc
2023-12-20 13:43:16 +01:00
Martin Prikryl
1d7d01ad70 PuTTY 0.80
Source commit: 04e78706e91713a0bbe3be3d75fc7882165d974a
2023-12-20 13:39:56 +01:00
Martin Prikryl
323b110246 Bug 2223: Some DLLs were not protected against hijacking
https://winscp.net/tracker/2223

Source commit: 7969689de8d933eb76d7646d8c867f4e1cbfa697
2023-09-28 01:04:24 +02:00
Martin Prikryl
db87bc1810 Bug 2145: Support for OpenSSH certificates for host verification
https://winscp.net/tracker/2145

Source commit: 9dda484bf38f9a72b61a2c3d8e7dd8892ee96c2b
2023-09-08 08:59:22 +02:00
Martin Prikryl
281f907939 Merge branch 'thirdparty_dev' into dev
# Conflicts:

#	source/putty/ssh/connection2.c
#	source/putty/ssh/ppl.h
#	source/putty/ssh/transport2.c
#	source/putty/ssh/userauth2-client.c

Source commit: 84a1449cae5af55c4a6671f80e82114fc0adc781
2023-05-22 17:22:05 +02:00
Martin Prikryl
f7bc002428 PuTTY Pre-release 0.79:2023-05-22.56b16bd
Source commit: b8854c20303cf71066ac3421b037f7bd737c21d6
2023-05-22 17:19:40 +02:00
Martin Prikryl
48106ee1b6 Bug 1873: Support for OpenSSH certificates for user authentication
https://winscp.net/tracker/1873

Source commit: fc13a226065092a102456a27242ac69151cb1d15
2022-12-14 01:00:41 +01:00
Martin Prikryl
ec808580ce Minimal changes needed to compile against PuTTY 0.78 and pass tests
Source commit: c717fcdc41b9be7bb3a88e06fc49d45eaf0cfa44
2022-12-03 00:57:29 +01:00
Martin Prikryl
53826431d2 Merge branch 'thirdparty_dev' into dev
# Conflicts:
#	source/putty/crypto/aes-select.c
#	source/putty/crypto/aes-sw.c
#	source/putty/crypto/aes.h
#	source/putty/crypto/arcfour.c
#	source/putty/crypto/blowfish.c
#	source/putty/crypto/chacha20-poly1305.c
#	source/putty/crypto/des.c
#	source/putty/crypto/dsa.c
#	source/putty/crypto/ecc-ssh.c
#	source/putty/crypto/hmac.c
#	source/putty/crypto/rsa.c

#	source/putty/ssh.h
#	source/putty/ssh/common_p.c
#	source/putty/ssh/kex2-client.c
#	source/putty/ssh/ppl.h
#	source/putty/ssh/ssh.c
#	source/putty/ssh/transport2.c
#	source/putty/ssh/transport2.h
#	source/putty/ssh/userauth2-client.c
#	source/putty/sshpubk.c
#	source/putty/utils/tempseat.c
#	source/putty/windows/agent-client.c
#	source/putty/windows/gss.c
#	source/putty/windows/network.c
#	source/putty/windows/storage.c

Source commit: ca42122a58b67cfc547e8691e9f22c1ed8356cd6
2022-12-03 00:56:05 +01:00
Martin Prikryl
a4b3791c54 PuTTY 0.78
Source commit: 4eba336bd557f717ffaa78be798684bf09042571
2022-12-03 00:54:15 +01:00
Martin Prikryl
0d555f8893 Bug 2113: Agent forwarding does not work
https://winscp.net/tracker/2113

Source commit: 885cffeb5bafd6e496cff8f948197d304f024110
2022-09-16 01:01:06 +02:00
Martin Prikryl
2d148fc649 Merge branch 'thirdparty'
# Conflicts:

#	source/putty/proxy/proxy.c
#	source/putty/windows/network.c

Source commit: f6c4f9badfec50adaf6ea0861446b536685ee49e
2022-06-03 00:59:04 +02:00
Martin Prikryl
0006b066e5 PuTTY 0.77
Source commit: 4460e89e63d91ff048baf208874bcb2ead90b835
2022-06-03 00:57:22 +02:00
Martin Prikryl
dc8f224072 Merge branch 'thirdparty'
# Conflicts:
#	source/putty/defs.h

#	source/putty/proxy/interactor.c
#	source/putty/windows/utils/security_p.c

Source commit: 509f872ef5f6de3f90a88cd64080498e93e95f85
2022-03-30 01:20:42 +02:00
Martin Prikryl
095f5140af PuTTY snapshot a101444d (New script to draw the icons as SVG – 2022-03-18 – current)
Source commit: 8c85471f1d873833dd2e36c97a111c0f297df200
2022-03-30 01:17:44 +02:00
Martin Prikryl
45ce42b255 Updating code to PuTTY 0.77 new local proxy implementation
Source commit: 2cb1dc43b06ee42ecdc13f21c774ce17328ef253
2022-03-29 01:10:35 +02:00
Martin Prikryl
52e2db4e1c Merge branch 'thirdparty'
# Conflicts:

#	source/putty/proxy/proxy.c
#	source/putty/windows/network.c

Source commit: 561d633766c4a1a191c50143b12b1aa2de9a3471
2022-02-24 01:04:09 +01:00
Martin Prikryl
6c875ff226 PuTTY 2022-02-22.d73a6d6
Latest version as on now, but primarily to get "HTTP proxy fixes"

Source commit: 78ea3fb48af64f32a6f306da5bc81d659932cf6e
2022-02-24 01:01:02 +01:00
Martin Prikryl
9dae2237ad Removing unused PuTTY source files
(cherry picked from commit 2ab20bb81b)

Source commit: e7a2e0d74967048861eaf0c19c53f6e4193bc1ef
2022-02-07 11:57:20 +01:00
Martin Prikryl
2ab20bb81b Removing unused PuTTY source files
Source commit: f3103e04f22d681fb6becbac1c0f15a344cb040a
2022-02-07 11:54:53 +01:00
Martin Prikryl
6c8cf9ae8d Updating code to PuTTY 0.77
Source commit: da47a0c8a6347ce05fd02167b644c05cef61dc28
2022-02-07 09:57:39 +01:00
Martin Prikryl
b21a098cc1 Merge branch 'thirdparty'
# Conflicts:

#	source/putty/misc.h
#	source/putty/network.h

#	source/putty/putty.h

#	source/putty/sshpubk.c

#	source/putty/storage.h

#	source/putty/windows/gss.c
#	source/putty/windows/handle-io.c
#	source/putty/windows/handle-socket.c
#	source/putty/windows/network.c
#	source/putty/windows/platform.h
#	source/putty/windows/storage.c

Source commit: 135140e906397a3426f77c0b3d2cf54f7a3ffed8
2022-02-04 19:47:59 +01:00
Martin Prikryl
936ab62732 PuTTY 0.77 2022-01-22 Pre-release
Source commit: fe07f3c4a6b19aa55f5b7d58e66cb55365edc059
2022-02-04 19:45:22 +01:00
Martin Prikryl
219bab96c7 Bug 2044: Provide private key as string in .NET assembly
https://winscp.net/tracker/2044
(cherry picked from commit 1018b272ea)

Source commit: 0c40d1ef172d932508fd1b89887ad2eefc5fbd26
2022-01-07 17:05:01 +01:00