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

147 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
Martin Prikryl
941ce4e50e Issue 2440 – When opening session in PuTTY to a host for which WinSCP has multiple hostkeys cached, use the last key or the key that PuTTY has cached
https://winscp.net/tracker/2440

Source commit: 7a596711a8c49cb70687679fe72aec92159ddf6e
2026-05-19 00:59:46 +02:00
Martin Prikryl
a2119a7eac Types and casts safe in respect to pointer size for forward 64-bit compatibility
Also GetWindowLongPtr and GWLP_USERDATA

https://winscp.net/tracker/618

Source commit: c85fdf15e50ce8a6f35b1c4d2a0125a0b9c4f1f0
2026-01-22 14:51:13 +01:00
Martin Prikryl
e5efed8955 Refactoring old-style casts
Source commit: 3c37b3a958525c595ad44b081b2e0f3b288b8eb0
2025-12-18 01:20:33 +01:00
Martin Prikryl
485e0b69fa Typo in logging
Source commit: e2ba0f03d05ffc33633faa82de02774d705739cf
2025-12-10 16:25:34 +01:00
Martin Prikryl
a5dcb5f03c Using std::size instead of custom macro
Source commit: 1a89c80dd42426351f261526b617534bab664208
2025-12-07 01:17:54 +01:00
Martin Prikryl
1d9fe8c955 Changing compiler to Clang/bcc32c
- regarding the ILINK_LibraryPath for Cfg_1_Win32 (Debug):
Win32\Debug (not only Win32c\Debug) needs to be before Win32c\Release, as win32c does not include debug builds of Pascal code - so without that VCL debugging won't work
- IDE insist on adding CC_Suffix to all projects once switched to Clang, although it is only used in WinSCP.cbproj
- UNICODE define: Not needed for build (it's implicit), but CodeInsight does not know it it somehow

Source commit: da06d73eb86caff5ca9cac0185bed54da0da8f07
2025-09-04 07:53:01 +02:00
Martin Prikryl
b13e2e7c2b #pragma package(smart_init) is not useful out of packages
Source commit: 7635ac3b532214f27ea2b6fe6aa80398c857cfcd
2025-08-23 01:06:48 +02:00
Martin Prikryl
3817bbd736 Preparing for separate pre-compiled header file required by Clang
- Once doing that, including more headers to PCH, not just vcl.h
- Clang won't need explicit include, but we will probably keep it anyway.
- #pragma hdrstop has no effect in Clang

Source commit: adc8a268b6907c5337ccaa430cca7526793a3019
2025-08-22 15:43:55 +02:00
Martin Prikryl
f7f00c631e 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

Source commit: 5c1338d95bd275082288dd1e773a033df6e379cd
2025-03-13 16:39:24 +01:00
Martin Prikryl
ef4e1e87ab Unused parameter
(it seems that it was never used)

Source commit: 7a61240971f9606d2156e588352db3f63d531e7f
2025-01-24 01:14:40 +01:00
Martin Prikryl
59a148c152 Updating code to PuTTY Pre-release 0.83:2025-01-03.1e45199 + Updating PuTTY code to C++ Builder
Source commit: f19842107de91d45c4a819260d5d335a7635980c
2025-01-05 01:04:26 +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
e09e95ee43 Upgrade to C++ Builder 11
Comments:
- .res files seem to be linked automatically, so explicit entries in project files caused duplicates
- JCL updated for compatibility with BCB11 (jcld28win32.inc obtained by running JCJ installer [uninstalled afterwards])

Source commit: ec28d10a0bbb346ed2bb3940aed37e777342e663
2024-10-08 07:18:18 +02:00
Martin Prikryl
85f0e92ca6 Timeout* counters
Source commit: ac2610bb1cafef757caed4ecc5b46c9065e6c719
2024-03-21 12:43:55 +01:00
Martin Prikryl
9f9d4655f1 Easier use of TValueRestorer
Source commit: 605e98cefaa62284f2b1150fdc355e88d48bdbd3
2024-03-20 13:56:00 +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
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
65423a6dfa Redesigning (and refactoring) host key prompts in anticipation of Bug 2145
Source commit: 178f136f5f65f1352cfa6fe5eb0071d8fefa5f6d
2023-09-05 14:14:09 +02:00
Martin Prikryl
f03d94d6c4 Unused code
Source commit: c1fbc8af76d8e2116aaf6d2026dba2ea3e5e1c8f
2023-09-05 01:12:41 +02:00
Martin Prikryl
4ed18b85ef Correcting error message when credential is missing with SSH protocol which retry the prompt (after acd12ea3)
Source commit: 9b7449274a60c0260767d0b8e80b20a9a6dd2b7f
2023-08-25 11:39:45 +02:00
Martin Prikryl
acd12ea3d7 More meaningful error message when credentials are missing in scripting and .NET assembly
Source commit: a374ebe71eea553a366120f46b8d3169ad735a7a
2023-08-25 01:10:22 +02:00
Martin Prikryl
3d27a5f88d Bug 2195: Ignore disconnects from the server while closing the connection
https://winscp.net/tracker/2195

Source commit: 4727939d067e9ba8140d50cd476c2c2d8ff9b134
2023-06-10 08:18:17 +02:00
Martin Prikryl
29a0b2d604 Bug fix: HTTP proxy authentication prompt was not localized
Source commit: 0c5f75ee62f004dfb160c2dbb4d48b98edc0b398
2023-03-22 01:03:30 +01:00
Martin Prikryl
9f2d18a8a9 Acknowledge inconsistent counter names
Source commit: 1f133e6c59e1717973bbba8d510e301d3519aa6d
2023-02-14 01:32:09 +01:00
Martin Prikryl
29b6be6f0a Support for NTRU Prime post-quantum key exchange
https://www.chiark.greenend.org.uk/~sgtatham/putty/wishlist/ntru.html

Source commit: 33d0e948a119c5cbdc61f22b30b0d5d2ed1b96d2
2023-01-07 00:54:35 +01:00
Martin Prikryl
952e9a2226 SSH ciphers usage counters
Source commit: 56b2213d85271f67c870d95061068c319bbd23d1
2023-01-05 19:29:15 +01: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
68a4dd04b7 Reimplementing host key algorithm display for /info in a way that does not need reorganizing PuTTY code to show them in the preference order
Side effect of this is that Ed448 is put correctly on the top

Source commit: da86732db01cdd2c7bd228ec7596097590af1ce9
2022-12-08 00:52:21 +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
2fdcc0e6ad Using unique_ptr instead of auto_ptr + Replacing use of auto_ptr, where unique_ptr cannot be used with plain pointers
Source commit: 0c397b15f93f20fcb52bdd7c8747aae8429f8b1e
2022-10-06 01:17:32 +02: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
070ff9ad32 Bug 2107: Private key pattern in PuTTY command-line
https://winscp.net/tracker/2107

Source commit: 9131c33ed478233657c25df035764a7cd1f03e4c
2022-09-01 00:54:29 +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
8c0e341973 Do not try to update network buffer, if there's no network socket
Source commit: c3ab4487d067b0f3dee0fe0b1d2d0664f922e279
2022-03-29 01:08:43 +02:00
Martin Prikryl
5c9ec290c6 Failure when connection lost is detected while waiting for data
Source commit: 21c2f09f91ebdc8d4049882c8d3b58c8658d5e36
2022-03-29 01:06:53 +02:00
Martin Prikryl
4c020b5f87 Redundant call
Source commit: 867b8b9d7073723027b9d12eb40ee1f9408c0674
2022-03-29 01:05:00 +02:00
Martin Prikryl
a9c8bf0510 Unused code
Source commit: 6d8285f6e0c0e53ffc5d7b22eb1fcfd770368a71
2022-03-29 01:03:05 +02:00
Martin Prikryl
a98d6af45e Fixing logging of multiple prompts
Source commit: 6e159df057fa287392dde99fd1a0f608c3b35568
2022-03-24 01:02:49 +01:00
Martin Prikryl
58be45f390 Updating code to PuTTY 0.77 proxy-password-prompt (Interactive username/password prompts for proxy authentication)
Source commit: 3812211a6544bc17e24c192137f0a5ae97c65e7f
2022-03-23 13:43:56 +01:00
Martin Prikryl
e5a92a4e1a Empty second banner was displayed when the actual banner did not end with new-line
Source commit: daa2692127c7bd9ad2ceca8848fa8f6393d070b3
2022-02-09 00:58:16 +01:00
Martin Prikryl
d8d7fdec31 Avoid redundant logging of known host keys
Source commit: 31f8a9b00711e88e14f2c41719202d24b850bc30
2022-02-09 00:55:51 +01:00
Martin Prikryl
6c8cf9ae8d Updating code to PuTTY 0.77
Source commit: da47a0c8a6347ce05fd02167b644c05cef61dc28
2022-02-07 09:57:39 +01:00
Martin Prikryl
96ae60100d Removing noop code
(cherry picked from commit ba3c2721a9)

Source commit: 319f4b5b3395fc0080c6f27968b93609017580bb
2021-11-26 15:51:39 +01:00
Martin Prikryl
0a567870cf Thread safe replacement of handles_by_evtomain global
Before it was used for local proxy command only, so probability of problems was relatively small. In PuTTY 0.75 it's used even for Pageant communication.

(cherry picked from commit 675cfb552b)

Source commit: e95234c0c1ab3db66d29fa4b321596cac02539e7
2021-11-23 21:03:38 +01:00
Martin Prikryl
cda4ea8a81 Removing support for SSH-1
(cherry picked from commit 5dfcf1eb9f)

Source commit: 1fd4286a576bf4525c8dd00849cdcf958cbf5eb8
2021-11-23 20:54:18 +01:00
Martin Prikryl
542b4ead44 Updating code to PuTTY 0.75
(cherry picked from commit b69328d92d)

# Conflicts:
#	source/putty/sshecc.c

Source commit: 93ff727e4e428f747ab8f6b0d2db8147905b9e26
2021-11-23 19:09:04 +01:00
Martin Prikryl
f074f481bf Bug fix: Do not say "Terminated by user" when the session has actually timed out.
(cherry picked from commit 1dc5bc03c9)

Source commit: e12c9159b6f2caa209e3017a4f08b4772cdfb581
2021-11-23 15:28:36 +01:00
Martin Prikryl
79f7c90fef Logging SSH authentication prompts responding
(cherry picked from commit 7ec3560bb8)

Source commit: 7fd555c45c64cad7f3a6a5c557d09ee35a61b904
2021-11-23 14:18:12 +01:00