curl-curl/scripts
Viktor Szakats 6d0ee7b17b
curlx: add curlx_rename(), fix to support long filenames on Windows
Move existing `Curl_rename()` `rename()` wrapper from lib to
curlx/fopen, and make it a curlx macro/function. To allow using
the local worker function to fixup long filenames on Windows.

Then fix the Windows-specific rename implementation to support long
filenames. This operation may happen when using a cookie jar, HSTS cache
or alt-svc cache, via libcurl or the curl tool.

Before this patch, when passing a long filename to the above options,
a `<random>.tmp` file was left on the disk without renaming it to the
filename passed to curl. There was also 1 second delay for each
attempted rename operation.

Also:
- checksrc: ban raw `rename()` and `MoveFileEx*()` functions.
- Note: `Curl_rename()` returned 1 on failure before this patch, while
  `curlx_rename()` returns -1 after, to match POSIX `rename()`.

Refs:
https://learn.microsoft.com/windows/win32/api/winbase/nf-winbase-movefileexa
https://learn.microsoft.com/windows/win32/fileio/maximum-file-path-limitation

Ref: #20040

Closes #20042
2025-12-20 16:03:11 +01:00
..
.checksrc REUSE: move copyright headers to .checksrc 2025-10-13 11:54:22 +02:00
cd2cd tidy-up: miscellaneous 2025-12-12 04:18:48 +01:00
cd2nroff docs: spell it Rustls with a capital R 2025-11-26 09:41:09 +01:00
cdall badwords: fix issues found in scripts and other files 2025-11-17 17:18:07 +01:00
checksrc-all.pl tests/data: move --libcurl output to external data files 2025-12-09 00:19:10 +01:00
checksrc.pl curlx: add curlx_rename(), fix to support long filenames on Windows 2025-12-20 16:03:11 +01:00
ciconfig.pl tidy-up: miscellaneous 2025-12-12 04:18:48 +01:00
cijobs.pl scripts: enable strict warnings in Perl where missing, fix fallouts 2025-07-27 22:35:18 +02:00
cmakelint.sh cmake: match filename suffixes with file content 2025-12-20 11:34:27 +01:00
CMakeLists.txt cmake: replace deprecated PERL_FOUND with Perl_FOUND 2025-12-17 17:56:32 +01:00
completion.pl badwords: fix issues found in scripts and other files 2025-11-17 17:18:07 +01:00
contributors.sh contributors.sh: only check -by: lines for names 2025-12-19 11:07:53 +01:00
contrithanks.sh contrithanks: fix for BSD sed tool 2025-07-28 17:29:26 +02:00
coverage.sh GHA: add shellcheck job and fix warnings, shell tidy-ups 2024-04-08 09:37:24 +00:00
delta tidy-up: miscellaneous 2025-12-12 04:18:48 +01:00
dmaketgz dmaketgz: use --no-cache when building docker image 2024-12-05 15:41:53 +01:00
extract-unit-protos scripts: enable strict warnings in Perl where missing, fix fallouts 2025-07-27 22:35:18 +02:00
firefox-db2pem.sh tidy-up: miscellaneous 2025-12-12 04:18:48 +01:00
installcheck.sh GHA: add shellcheck job and fix warnings, shell tidy-ups 2024-04-08 09:37:24 +00:00
Makefile.am lib: stop overriding system printf symbols 2025-10-06 20:57:59 +02:00
maketgz scripts: use end-of-options marker in find -exec commands 2025-11-10 18:52:29 +01:00
managen tidy-up: miscellaneous 2025-12-18 21:27:58 +01:00
mdlinkcheck mdlinkcheck: only look for markdown links in markdown files 2025-12-11 23:40:07 +01:00
mk-ca-bundle.pl tidy-up: miscellaneous 2025-12-12 04:18:48 +01:00
mk-unity.pl cmake: replace the way clang-tidy verifies tests, fix issues found 2025-06-22 23:08:46 +02:00
nroff2cd scripts: enable strict warnings in Perl where missing, fix fallouts 2025-07-27 22:35:18 +02:00
perlcheck.sh cmake: match filename suffixes with file content 2025-12-20 11:34:27 +01:00
pythonlint.sh scripts: move the ruff linter command into a script 2025-05-13 16:41:32 -07:00
randdisable spelling: file system 2025-08-22 15:53:41 +02:00
release-notes.pl badwords: fix issues found in scripts and other files 2025-11-17 17:18:07 +01:00
release-tools.sh badwords: fix issues found in scripts and other files 2025-11-17 17:18:07 +01:00
schemetable.c tidy-up: miscellaneous 2025-12-12 04:18:48 +01:00
singleuse.pl singleuse.pl: fix string warning 2025-10-28 11:34:19 +01:00
top-complexity badwords: fix issues found in scripts and other files 2025-11-17 17:18:07 +01:00
verify-release verify-release: update to avoid shellcheck warning SC2034 2025-11-10 16:06:48 +01:00
wcurl wcurl: import v2025.11.09 2025-11-10 08:52:55 +01:00