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

58 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
afbaf8f9ea Shared BOM declaration
Source commit: cba15f59434ab48b2f30e93d304e8e3fcffd0463
2026-01-22 14:53:05 +01: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
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
74fdf539de Clang imposed changes that should be noop and have no effect on classic compiler (2nd after 92ba1e3f0 + preceding commits)
Mostly
– explicit static global variables
– const, sign and down casts safety
– same-named variables in nested scopes
– incorrectly identified uninitialized variables
– semicolon after function implementation
– unused variables, fields, arguments and macros
– exact include filename case
– field initialization order
– typename use
– struct vs class declarations
– incorrectly identified uninitialized variables
– refactoring to solve Clang internal compiler error when using new variable in __finally block

Source commit: 3da995ff5169eefcfe3b3b7cc0d019c660096c07
2025-06-24 16:32:34 +02:00
Martin Prikryl
7b54dde3a6 Clang identifies some functions as "noreturn" + one noexcept(false)
Source commit: fc0c35fdddcd50a10d9ca13fc515164885325f81
2025-03-14 16:15:03 +01: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
4019b56ffb 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

Source commit: 693ecd9b083f1460dc4d1ae1ff49e625989f8a50
2025-03-13 06:36:08 +01:00
Martin Prikryl
5e33daf15f Issue 2301 – Some Unicode texts, notably custom command names, were saved incorrectly in an INI file
https://winscp.net/tracker/2301

Source commit: d4e2d35de89e549991b2d661c86bce8f52b27f3f
2024-07-10 13:13:46 +02:00
Mikhail Lukashov
a8e6220b88 fix typos 2024-01-05 10:37:32 +01:00
Martin Prikryl
4cf1ac20db When cleaning up application data, deleting even Martin Prikryl and WinSCP 2 root keys, if they remain empty
Source commit: 59d177a9304cb8d627e2c2c967b7d9f725753114
2024-01-03 16:41:50 +01:00
Martin Prikryl
46cacc3db3 Bug fix: Configuration reading was broken after an attempt to access a non-existing sub-section within a section existed in raw configuration only
Source commit: 2c62787d00b360c9720f3753917544666861df30
2023-09-08 08:57:20 +02:00
Martin Prikryl
327a00dbd8 ProxyMethod raw session setting supports symbolical value names
Source commit: 0f00739cec07a65621abdb5fdb33b396c13563db
2023-06-06 01:04:28 +02:00
Martin Prikryl
b1121ad72f Memory leak
Caused by 71ea2a97

Source commit: cc00c4f0789476839c1a7be9ca8e26c0f28e8b9b
2023-04-21 00:59:28 +02:00
Martin Prikryl
71ea2a977a Bug 2163: Workaround for using /ini=nul on systems when reading "nul" file fails
https://winscp.net/tracker/2163

Source commit: 2a222baa93187e05a2b7c286015bb1ede9146fa1
2023-02-03 01:01:44 +01:00
Martin Prikryl
f10f089958 Bug fix: Configuration does not load when using /rawconfig command-line switch and read-only configuration sections
Source commit: 2be9d787d40a9640dd286f7cee2e8406ff0ef9dd
2022-09-21 01:01:59 +02:00
Martin Prikryl
1b198d1cc3 Removing OpenRootKey assertion invalidated by bf9594fd and probably never needed + Though adding another assertion to generally suspicious OpenRootKey code.
Source commit: 9aa8a3bcd07310773a0ef1b8900186ae8e26e557
2022-09-01 00:52:31 +02:00
Martin Prikryl
fb707f79f3 Factoring out NotImplemented()
Source commit: 7a72c7024d5636476d85c4ef6ac837654d2224c9
2022-07-02 01:03:28 +02:00
Martin Prikryl
2dd517c888 Switch-like raw session settings can be configured using on/off/auto keywords
Source commit: 899e6c7fee15d2bb8c3fcdcfe77ff47938c222f2
2021-01-21 16:00:43 +01:00
Martin Prikryl
8c646ce6af Bug fix: Cleaning up cached SSH host keys did not work + Cleaning up configuration did not remove jumplist
Caused by 7861d4c8

Source commit: 92f018ea3bacd86894989c4f658123556619b62d
2019-11-14 02:05:54 +01:00
Martin Prikryl
46a9c8fed9 Bug 1798: Allow configuring additional PuTTY settings (e.g. terminal settings) to be used when opening a session in PuTTY
https://winscp.net/tracker/1798

Also fixes a build broken by eef27ac3 (and still not fixed by 5d189553)

Source commit: 0bd13d447e6da8427be1506b7c561d74e83b1b85
2019-10-11 01:56:00 +02:00
Martin Prikryl
b93bd1246f Bug fix: Settings with an empty default value were not listed in Add Raw Site Settings dialog
Source commit: 0d01127ceaebf85fe1ea4d675a83dcc57bc8c97b
2019-10-10 01:23:07 +02:00
Martin Prikryl
1b196e756b Bug 1787: Better error message when writing INI file fails
https://winscp.net/tracker/1787

Source commit: 192462c771c854e83afb615f7379970d8a896c7e
2019-09-18 00:42:57 +02:00
Martin Prikryl
b0bc42919c Bug 1775: Keep trying to save configuration for up to 2 seconds when INI file is locked by another process
https://winscp.net/tracker/1775

Source commit: 682e051d1d05f6c5a043f8dac043146dedf67984
2019-08-05 00:56:25 +02:00
Martin Prikryl
dc142dfa65 Unused variable (introduced by 7861d4c8)
Source commit: b8d4aaa87fc43e27f4856ead2d93b188040f3911
2019-07-11 02:06:22 +02:00
Martin Prikryl
7861d4c851 Individual configuration storage sections can be set read-only
Source commit: 832ea7efbd56d8520fb2073c95705db4bec6d3c3
2019-07-10 01:44:13 +02:00
Martin Prikryl
bca358e5b4 KeyExists did not work for virtual keys in INI file
Source commit: c86f743db34e95dfadaaef671404bf1c6ac89366
2019-07-10 01:31:03 +02:00
Martin Prikryl
a97ad26857 OpenSubKeyPath instead of Path parameter of OpenSubKey (better interface + should ease implementation of ACL)
+ Additional key open failure tests

Source commit: eb41469ccb54bd2b532ca64f64b399a3944b2b1c
2019-07-07 01:53:09 +02:00
Martin Prikryl
d3d7df483e Introducing methods to centrally control access to storage values and keys in anticipation of storage ACL implementation
Should be noop change.

Source commit: 98f893d1413cabc8d2d123acb092765dcee32070
2019-07-05 03:52:30 +02:00
Martin Prikryl
2662c867b2 HasSubKey and KeyExists seem to do the same thing
Source commit: 130f1d63d92e0e12632a874e8ecc3d1121807492
2019-07-02 01:01:59 +02:00
Martin Prikryl
7c2cbf1263 Bug fix: Corrupted binary data in primary storage were not identified when using /raw* switches
Source commit: 9acd9e15b33cb2954bf642e31952f1339fbad5a4
2019-07-02 00:47:09 +02:00
Martin Prikryl
9dc9efbbc8 Comment on purpose of TRegistryStorage::Copy
Source commit: c764acaf0dca2aa14738ba2702f078959372c753
2019-06-29 01:46:08 +02:00
Martin Prikryl
a2348fd6b9 Refactoring (mostly passing strings by const reference + use of auto_ptr)
Source commit: fd3a17b128b0373578a4a7f98d7286f224591325
2019-06-29 01:33:27 +02:00
Martin Prikryl
2e797b96b7 Reimplementing TRegistryStorage::Read/WriteInt64 using Read/WriteBinaryData
Source commit: fd6fc57c7da7dfc8ef693847c980b5cec6eae325
2019-06-29 01:20:26 +02:00
Martin Prikryl
c9ff171f70 Comment on purpose of used of ValueExists when reading registry values
Source commit: 2f46b348464a667987d8093deed1104ae0fb9b2a
2019-06-29 01:07:53 +02:00
Martin Prikryl
478471edcd Removed unused property
Source commit: 046c2bbfa007d17388062845fa609c133164e979
2019-06-29 00:55:08 +02:00
Martin Prikryl
2509af44b8 Typo in a comment
Source commit: bd7f398bf48553b0b4b96809ed298e6c448657ae
2019-06-28 01:39:13 +02:00
Martin Prikryl
1736013ede Updating code to PuTTY 85770b20
Source commit: 0e857a27e6048eb749220759e5b7fafa75dc97fa
2019-04-25 01:00:38 +02:00
Martin Prikryl
1d4e4569a0 Bug 1706: Tool for clearing broken COM registrations
https://winscp.net/tracker/1706

Source commit: 4657333708eef2015581028778c5bd271b716088
2018-11-24 01:48:45 +01:00
Martin Prikryl
4245e45bf3 Refactoring
Partially returning to the previous version of the code before 5.0, as the changed code seems unnecessarily complicated

Source commit: 5b4cb012b89ab1126100a22df7298ceeaa315f3d
2018-11-23 01:08:57 +01:00
Martin Prikryl
bae86205de Configuration can be saved to read-only INI file by holding down Shift key while closing WinSCP or submitting Preferences dialog.
Source commit: bb0f5310f5c6d4c975b102154d394a3a1c292591
2018-08-03 01:50:28 +02:00
Martin Prikryl
c16fd9a54b Function "Keep remote directory up to date" can be started in a new window
Source commit: 2cb0af9c9fd298daecd8df6096cd20536377e51f
2018-03-14 17:37:01 +01:00
Martin Prikryl
7a3c5eac79 Bug 1578: Mask out passwords in raw settings (proxy and tunnel) when logging command-line (2nd try for logging suggested "open" command) + Do not munge * in password (or in general in URL)
https://winscp.net/tracker/1578

Source commit: 659e267edb785ef4c69e07d3e76d23048709da9a
2018-01-28 16:15:22 +01:00
Martin Prikryl
4b27e2e834 Bug 1523: Failure when INI file cannot be opened
https://winscp.net/tracker/1523

Source commit: 6549953dc304424256eac517bf6137600d5d6d27
2018-01-28 06:20:10 +01:00
Martin Prikryl
092c24d412 Bug 1436: Some scripting commands or command-line switches were not recognized on some locales (like Welsh) when used or defined with a mixed case (like /XmlLog vs. /xmllog)
https://winscp.net/tracker/1436

Source commit: 81e27b5c5e4ae826955e2646cab1d21414d69eca
2018-01-26 11:55:51 +01:00
Martin Prikryl
f2ce5adc98 Compiler warnings discovered by build server
Source commit: 3a3e2b040db3bae9377e34ddf81cab612ee07604
2018-01-25 21:14:47 +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