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

71 Commits

Author SHA1 Message Date
Martin Prikryl
6f39a04987 Issue 2475 – Support client certificates with intermediate certificate
https://winscp.net/tracker/2475

Source commit: 7075ae74fd7e6cd92ed8d8e7422528dc56743158
2026-10-22 00:36:04 +02:00
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
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
efe94d6c08 Using actual types and functions instead of WinAPI and Unicode/Ansi macros
Source commit: b7fec4d069296b58bb43e7a4a97dd85d558212b7
2025-12-21 01:34:21 +01:00
Martin Prikryl
9cf851dcfa Replacing MFC CFile::IsValid with FileExists
Source commit: 48c7984e36261a8cee5f6eb09c896a8bf4ae0caa
2025-12-20 12:29:55 +01:00
Martin Prikryl
63a9eb579a Getting rid of MFC string loading code
Source commit: 3c7399548535aeb9ebb738e2fdde52431d0ba83f
2025-12-19 07:35:02 +01:00
Martin Prikryl
092180d4a7 Getting rid of MFC Ansi-Unicode conversion code
Source commit: f290d70e75fd2de0ae4c45e8480e766c2a8af5d0
2025-12-19 01:20:41 +01:00
Martin Prikryl
e5efed8955 Refactoring old-style casts
Source commit: 3c37b3a958525c595ad44b081b2e0f3b288b8eb0
2025-12-18 01:20:33 +01:00
Martin Prikryl
ad7a0626fd Refactoring certificate parsing
Source commit: 30a4ee26414f88408675d63ffee2b57be6a6c156
2025-12-17 01:39:05 +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
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
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
a23e73c987 Further removal of unused MFC code
(Neither CTime nor CString throws any CException)

Source commit: d4432854a7b73218a52cd92a9542d7f18e02ea27
2025-07-29 13:21:42 +02:00
Martin Prikryl
f39dfdd8a0 Comment on possibly better session caching API
Source commit: 0c133f95ea06feecbd5753f33607c7d90b79a3b1
2025-07-16 10:36:14 +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
ae9b173170 Issue 2327 – Failure when opening TLS connection with invalid OpenSSL configuration file
https://winscp.net/tracker/2327

Source commit: ee33d2badfff95c721fe412c86e7b305674e6703
2024-11-20 01:09:37 +01:00
Martin Prikryl
15112f5277 Issue 2299 – Better error message when server is using incompatible TLS protocol version
https://winscp.net/tracker/2299

Source commit: 03997d32ab26920b5c4c3fb934e1595db6fe8d38
2024-07-08 01:19:53 +02:00
Martin Prikryl
aa2b34138d Not including useless OpenSSL states in error reporting
Source commit: 627ff74a4254d728b9a431e91f4e12e5b0950fdc
2024-07-08 01:16:07 +02:00
Martin Prikryl
b46fe1542e Refactoring OpenSSL error reporting
Source commit: d11398667377b71f4dd18c9223e52ee9d978b25f
2024-07-08 01:11:21 +02:00
Martin Prikryl
248a021cc7 Issue 2261 – Random hang/failure when closing FTP TLS 1.3 connection
https://winscp.net/tracker/2261

Source commit: 83db5b84f18796ff2923bfeb25cb8a5cad31aa16
2024-02-21 13:45:52 +01:00
Martin Prikryl
c97a8ab847 Issue 2250 – Configurable FTP TLS shutdown procedure
https://winscp.net/tracker/2250

Source commit: 509a6c3b0efed21c398810e7ead00bd9235ee35d
2024-01-15 15:33:10 +01:00
Martin Prikryl
532f1847b2 Use up-to-date OpenSSL API + Use the same API to retrieve cipher suites for /info, as we use for neon (and indirectly for FTP too)
Noop change (currently SSLv23_client_method is just an alias to TLS_client_method, same for TLS_method vs SSLv23_method

Source commit: d35fcf2fbb722795f1ef267051892f0a931e2ab2
2023-12-07 01:08:06 +01:00
Martin Prikryl
d506d4419a Bug 2210: TLS session resumption is not working for subsequent FTP data connections with TLS 1.3 with some servers
https://winscp.net/tracker/2210

Undoes related and obsolete Bug 2018

Source commit: 8ebb50c550bc2b7c93e2aa552deb3bf3f036ce98
2023-08-07 01:12:13 +02:00
Martin Prikryl
1fdf58c748 Refactoring SSL globals
Source commit: ce896c4cb6db7ab2a2f28bdf11498946610b8c9a
2023-08-06 00:59:57 +02:00
Martin Prikryl
07e0374351 Unused code
Source commit: 86aeed9a76c8110a4ce96319a57177cf194e420a
2023-08-03 01:09:54 +02:00
Martin Prikryl
e5628b72f3 Bug 2019: Error when uploading file sized just below 32 kB boundary to FTP server over TLS 1.3
https://winscp.net/tracker/2019

Source commit: 20c418a5e796357ab6e842d95bf3614a21f1e4fc
2023-01-18 01:01:37 +01:00
Martin Prikryl
01b2a64d2c Factoring out ProcessSendBuffer
Source commit: 48e8642d9b3be79faf90d366021e4f91e058d12d
2023-01-17 01:19:10 +01:00
Martin Prikryl
85b1e9cb3d Optimizing use of USES_CONVERSION
Source commit: 41bec5877bfdf64a71ff054abe8849b94744330f
2022-05-17 12:29:49 +02:00
Martin Prikryl
3a2d8d6587 Prevent hang when closing TLS connection after transfer cancel
Related to 2c0b486d, 5d68c005, aff5cba7. Caused by 268f6355.

Source commit: e86e1b454952412b21774c65910d81f2d9ecf426
2021-10-27 01:22:36 +02:00
Martin Prikryl
aff5cba787 Prevent hang when closing TLS connection after network failure
Related to 2c0b486d, 5d68c005. Caused by 268f6355.

Source commit: 095c15c2ed15e8cfd517a3aebf1665d60d6b5977
2021-10-22 00:56:18 +02:00
Martin Prikryl
e70fd8fa51 Bug 2034: Custom certificate store file
https://winscp.net/tracker/2034

Source commit: 2dc42a32b9eb1c2777e61c0cec52c08ecac90a73
2021-10-20 00:57:39 +02:00
Martin Prikryl
5d68c005f1 Deadlock when TLS connection is lost
Source commit: 9561e7b58ff3a659c8eff1152efee28bf09d96e5
2021-10-13 00:49:10 +02:00
Martin Prikryl
12a3508797 Limiting scope of Bug 2030 (Timeout while uploading files to some FTP servers using TLS 1.3) to affected servers only
https://winscp.net/tracker/2030

Source commit: 83123c9e8d158ae74d541b5b07c88303c5ec7fe6
2021-10-11 15:28:58 +02:00
Martin Prikryl
2c0b486de5 Deadlock when closing connection when TLS was never established (caused by 268f6355)
Source commit: 24d6adda3af26be8871a9973338011cfe8d0c86c
2021-10-05 00:51:20 +02:00
Martin Prikryl
268f63557e Proper TLS shutdown
Source commit: 86a380532057c0d913678b9ca910cb319a8f422c
2021-10-02 00:56:44 +02:00
Martin Prikryl
e27595b329 Fixing indentation
Source commit: 7f8b13cf38fbc0ab62e2f04bc6cc1be81416d452
2021-10-02 00:54:49 +02:00
Martin Prikryl
b8e2cadde6 Partially restoring code removed by f7064be2 (Bug 2030: Timeout while uploading files to some FTP server using TLS 1.3)
https://winscp.net/tracker/2030

Source commit: 44c1fbf7b3c04eb9018264f4d4cc83f44c27d048
2021-10-02 00:52:50 +02:00
Martin Prikryl
f7064be2ce Bug 2030: Timeout while uploading files to some FTP server using TLS 1.3
https://winscp.net/tracker/2030

Source commit: bc5a4aaada2515c192316ad96aa2f2727fb6de34
2021-10-01 00:50:35 +02:00
Martin Prikryl
1f32f22044 Bug 2018: TLS session resumption is not working for subsequent FTP transfers with TLS 1.3 when the server requires reuse of the session of the previous transfer
https://winscp.net/tracker/2018

Source commit: 6cae14d95212b5de26a9ce611e258d6d7516c69b
2021-08-25 00:46:56 +02:00
Martin Prikryl
07b4e9d99c Bug 1966: Failure when connecting to FTPS server that supports client certificates with translation that uses multi byte encoding
https://winscp.net/tracker/1966

Source commit: e865233fb7f0b73898b6f2a4da0f9d54d4219d15
2021-03-24 00:47:04 +01:00
Martin Prikryl
a25c55a621 Bug 1895: Support for SNI with FTP (2nd)
https://winscp.net/tracker/1895

Source commit: fa44a4abb0d3bed4ab39df8590d359a2778e976c
2020-08-22 05:39:31 +02:00
Martin Prikryl
9fc806972c Bug 1895: Support for SNI with FTP
https://winscp.net/tracker/1895

Source commit: 224eb8909cfb253bf3994d0f77e62adcc21f0e7a
2020-07-31 03:11:27 +02:00
Martin Prikryl
b8814aafe3 Merge branch 'master' into dev
# Conflicts:
#	source/core/Terminal.cpp

Source commit: 0245fce5a9188dfcd8f2c33e2c76c8b5785ba637
2020-04-24 02:28:10 +02:00
Martin Prikryl
cf7a87cc32 Limit impact of e78c2485 to TLS 1.3 only
https://winscp.net/tracker/1834

Source commit: d4f10f2624093a4781a579b8c041b64c9d6661c4
2020-04-24 01:16:16 +02:00
Martin Prikryl
e78c2485a0 Bug 1834: FTP file uploads are interrupting with TLS 1.3
https://winscp.net/tracker/1834

Source commit: ed1a795deeb85606fa2ebb3cb265a407b5abfbef
2020-04-23 01:15:22 +02:00
Martin Prikryl
1fe119535a Bug 1842: Support SHA-256 fingerprints of TLS/SSL certificates
https://winscp.net/tracker/1842

Source commit: 66b808783a0b67b0277fff65af905cb132573175
2020-03-31 02:25:42 +02:00
Martin Prikryl
37fb62021d For TLS 1.2 and older, session reuse was not logged
(broken by 22beed90)

Source commit: 8a91bcc3d2acae25e8591608a4e3b0796a9e12f9
2020-03-08 01:24:18 +01:00
Martin Prikryl
22beed90db Bug 1831: TLS session resumption is not working for FTP transfers with TLS 1.3
https://winscp.net/tracker/1831

Source commit: ccd8c878571598701a86ed2f809eec31e822654a
2020-03-07 02:03:08 +01:00
Martin Prikryl
0e4e2e6bc8 It is possible to configure TLS 1.3 restrictions
(+ reusing SetupSsl for FTP)

Source commit: 426bf5c70861f8a2964967d32ef5b5e36bbb1ac6
2020-02-12 00:52:11 +01:00
Martin Prikryl
304051da58 TLS/SSL session resuming was broken since OpenSSL 1.1.1
The SSL_ST_CONNECT now happens the first time before session reuse is tested, so SSL_session_reused returned false. Moving SSL_session_reused test to SSL_CB_HANDSHAKE_DONE.

Source commit: b6ed90779ec5bdd737e7688256afd3457a6cffab
2019-06-21 01:51:14 +02:00