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

41 Commits

Author SHA1 Message Date
Martin Prikryl
6542254ab9 Fix compile error by a8fc40bd
NULL cannot be used with closure in ternary operator

Source commit: f8e68bf54e4d8ce76e5f0cd7ee4bc27cd2528daf
2026-10-21 07:43:16 +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
dc56db76b1 Issue 2447 – Do not allow WebDAV redirects to other hosts by default + Issue 2448 – Do not allow WebDAV redirects to an unencrypted URL by default
https://winscp.net/tracker/2447
https://winscp.net/tracker/2448

Source commit: c777084ca5737c4283f256eb8cdf5c2fec5902af
2026-06-13 01:00:40 +02:00
Martin Prikryl
e500e57baa URI class
Source commit: baa68e01bcc829b3c66842aec637fe1b6febd48a
2026-06-10 16:13:11 +02:00
Martin Prikryl
5a8c4cdaea Using "username" and "hostname" as one word
Source commit: d86c0d6704a14fff6e3dca57868548df1f80cdd7
2026-05-29 01:15:26 +02:00
Martin Prikryl
e5efed8955 Refactoring old-style casts
Source commit: 3c37b3a958525c595ad44b081b2e0f3b288b8eb0
2025-12-18 01:20:33 +01:00
Martin Prikryl
db7648e1b8 Issue 2404 – Do not redundantly verify WebDAV or S3 certificate in Windows Certificate store if it is already marked as trusted in session settings
https://winscp.net/tracker/2404

Source commit: 69f696bc9c5ca484e2c4e6b46428e6d8b90a876e
2025-10-16 14:32:18 +02: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
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
3fe2be7429 Neon build corrections identified by Clang
- ne_session.h is not included by ne_socket.c, so ne_init_ssl_session wasn't declared
- OPENSSL_NO_SOCK cannot be used as neon calls at least SSL_set_fd
- USE_GETADDRINFO is already defined in config.h
- config.h is included repeatedly

Source commit: 406788b333986f3cee1667617f453dd28fb62dfb
2025-07-19 01:14:12 +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
eab9b315c6 Making compilable after 400bee57
Source commit: 8c6323e24bc6c046a8b53c06810bec84dfb6e3f9
2024-12-25 11:48:36 +01:00
Michael Lukashov
400bee57cf minor: Fix typos (#59)
Fix various minor typos
2024-12-25 11:25:35 +01:00
Martin Prikryl
21b414bbcd Using SSL_set_min_proto_version and SSL_set_max_proto_version to control TLS/SSL version used
Source commit: d5c36221605624481143deebe7b85770be0bd507
2024-12-05 14:01:45 +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
b1c505cadb Custom certificate store stopped working for S3
Caused by 9ffd61b6

Source commit: d77e91b0ce88205b0a075ea04c52ec88217a4e56
2023-08-19 01:11:10 +02:00
Martin Prikryl
9ffd61b6df Bug fix: Potential failure when opening unencrypted HTTP/WebDAV connection
Caused by Bug 2034

Source commit: b93f34c4e00ed58793e788815e55ddf0b07707f9
2023-08-18 01:22:34 +02:00
Martin Prikryl
699bf5fd2c Bug fix: Check for application updates was limited to TLS 1.2
Source commit: 947be1b917051e314e5e52e637297cb50cd57030
2023-08-18 01:03:43 +02:00
Martin Prikryl
52cec785ee Improving HTTP error reporting
Source commit: 5960b633e486c4a8e2d05a1246c89b2120754a06
2023-06-21 01:28:16 +02:00
Martin Prikryl
16f4adbc8f Bug 2197: Localized HTTP connection error messages are incorrectly decoded
https://winscp.net/tracker/2197

Source commit: 70802c6c410ac321d5eff675757ce1cf6d25115e
2023-06-21 01:11:29 +02:00
Martin Prikryl
6897b31097 Since OpenSSL 3, SSL 3.0, TLS 1.0 and 1.1 are enabled on security level 0 only
Source commit: e3258aa4b0246698b9a7660e11c4c420960a9a11
2023-05-17 01:08:33 +02:00
Martin Prikryl
1ce08e128f Merge branch 'master' into dev
Source commit: b9b733dcfea3a104793aa8bedc7947f415957830
2021-10-22 01:13:35 +02:00
Martin Prikryl
7cf94ff42a Logging a use of certificate store file
(part of Bug 2034)

Source commit: e7f1625dcb6a846ac2489409e34458f0f3f6a83d
2021-10-22 01:11:31 +02:00
Martin Prikryl
a411a0072f Bug 2034: Custom certificate store file (with fixed path only)
https://winscp.net/tracker/2034

Source commit: f346dbf0071056e1f62fb157ac2abb0d3ca8ab40
2021-10-22 01:07:10 +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
4a1ce1c673 After update to neon 0.32.1 and 7d9dbdcf, SHA-256 fingerprint of TLS certificate was missing colons
Source commit: a74063cfc658b497af62831dd4748a7ed678561c
2021-09-23 00:49:32 +02:00
Martin Prikryl
7d9dbdcf83 Updating code to neon 0.32.1
The new ne_ssl_cert_hdigest supports SHA-256, so we can get rid of our modified API of ne_ssl_cert_digest
(the modified implementation was already removed by the merge of neon 0.32.1 in 2cb17502)

Source commit: c148b3a49fa03139e96e9f288fa013a1530d4d9c
2021-09-22 00:55:48 +02:00
Martin Prikryl
90d27a6ac8 Bug 1842: Support SHA-256 fingerprints of TLS/SSL certificates
https://winscp.net/tracker/1842
(cherry picked from commit 1fe119535a)

Source commit: b59b582a91ec48585f48998b6f91ca7ec625bc8b
2020-11-26 11:25:11 +01: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
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
b86225042c Update to OpenSSL OpenSSL 1.1.1a
Source commit: ed68069c4ffc356398506b3529414ebace044caf
2019-01-29 16:12:34 +01:00
Martin Prikryl
7c0e13e33b Bug 1637: Low logging level (S3 and partly WebDAV)
https://winscp.net/tracker/1637

Source commit: 6dc112edd1eae10916bc25717ec6581948db1abb
2018-10-25 04:51:10 +02:00
Martin Prikryl
3259d040b4 Bug 572: Amazon S3 protocol (upload)
https://winscp.net/tracker/572

- FILE_OPERATION_LOOP_END reimplemented using FileOperationLoopEnd
- ReadFile refactored - as a side effect, it now reports a correct file path in error message

Source commit: fc577c6da1425794ae49674de27205962735e85a
2018-01-28 17:10:21 +01:00
Martin Prikryl
80e08f8d60 Bug 572: Amazon S3 protocol (directory browsing)
https://winscp.net/tracker/572

Counter StoredSessionsCountS3

Source commit: 20585d3ea3566ee2b638791549e28179eaefbc01
2018-01-28 15:02:56 +01:00
Martin Prikryl
a7883eda14 Decoupling neon debugging from WebDAV
Source commit: a46fc7f1af4fe73d6c01e56e4e2571113f6d52f2
2018-01-28 14:25:24 +01:00
Martin Prikryl
b4df71734a Bug 1479: Handle dav:// URL
https://winscp.net/tracker/1479

Source commit: c2dd8d68e98b48354a9a60c33b35a1ab7e35efb1
2018-01-27 23:21:44 +01:00
Martin Prikryl
7550bec1ea Bug 1465: Support Microsoft Passport authentication to allow WebDAV access to OneDrive
https://winscp.net/tracker/1465

Source commit: 8c6798a0d8fef2b7d738f4d6667c9fc713976a05
2018-01-27 13:07:19 +01:00
Martin Prikryl
a0a3e03326 Providing more details when verification of the TLS certificate against Windows certificate store fails
Source commit: ae4f02bf530e8ca88ad2166c0cd9c46b3d3e80a5
2018-01-26 02:20:33 +01:00
Martin Prikryl
b55e9565da Function call-line syntax for DebugFail + Replacing all DebugAssert(false) with DebugFail
Source commit: 358df59fa46a04bd1b2a141b826fa5c499303ae6
2018-01-24 20:47:51 +01:00
Martin Prikryl
987728ea0c Prettifying debug macros
Source commit: ba529d34782876686ca07031e9c0b7c17f9e92fd
2018-01-24 20:39:55 +01:00
Martin Prikryl
d8f92984b9 First public commit of dev branch
Source commit: 98cb9d870efc1c60826db4398ec35c5cbe809e6a
2018-01-24 14:13:46 +01:00