-
-
Notifications
You must be signed in to change notification settings - Fork 7k
curlx/fopen: replace open CRT functions their with _s counterparts (Windows)
#19643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Issues:
|
This comment was marked as off-topic.
This comment was marked as off-topic.
|
Fine, pytests broken (test_17_ssl_use, 20 variants failed) after Homebrew bumped wolfSSL to 5.8.4 (from previous release 5.8.2): https://github.com/wolfSSL/wolfssl/releases/tag/v5.8.4-stable → #19644 |
Cherry-picked from curl#19643
Cherry-picked from curl#19643
The safe (`_s`) variants of the Windows `open()` reject these flags, while the classic ones silently accepted them. Also: - also drop the now unused `stat()` call on Windows. - replace magic number with their equivalent Windows and Unix-specific `S_*` macros. Refs: https://learn.microsoft.com/cpp/c-runtime-library/reference/open-wopen https://learn.microsoft.com/cpp/c-runtime-library/reference/fstat-fstat32-fstat64-fstati64-fstat32i64-fstat64i32 Cherry-picked from #19643 Closes #19645
Ref: https://learn.microsoft.com/cpp/c-runtime-library/reference/open-wopen Ref: #19645 Cherry-picked from #19643 Closes #19647
…ision Windows CRTs have a `share.h`. Before this patch when trying to `#include <share.h>` it, the compiler picked up curl's internal `lib/share.h` instead. Rename it to avoid this issue. CRT `share.h` has constants necessary for using safe open CRT functions. Also rename `lib/share.c` to keep matching the header. Ref: https://learn.microsoft.com/cpp/c-runtime-library/sharing-constants Ref: 625f2c1 #16949 #16991 Cherry-picked from #19643 Closes #19676
Replace: - `open()` with `curlx_open()` (1 call). - `fopen()` with `curlx_fopen()`. - `fclose()` with `curlx_fclose()`. To centralize interacting with the CRT in preparation for using "safe" alternatives on Windows. This also adds long-filename and Unicode support for these operations on Windows. Keep using `open()` in the signal handler to avoid any issues with calling code not allowed in signal handlers. Cherry-picked from #19643 Closes #19679
https://learn.microsoft.com/cpp/c-runtime-library/reference/open-wopen https://learn.microsoft.com/cpp/c-runtime-library/reference/sopen-s-wsopen-s https://learn.microsoft.com/cpp/c-runtime-library/reference/freopen-wfreopen https://learn.microsoft.com/cpp/c-runtime-library/reference/fopen-wfopen https://learn.microsoft.com/cpp/c-runtime-library/reference/fopen-s-wfopen-s https://learn.microsoft.com/cpp/c-runtime-library/reference/freopen-s-wfreopen-s
|
TL;DR the reason for the CI failures seen earlier in #19581 (comment) were:
These were addressed in this PR and a series of separate commits today. |
|
CRT functions flagged by
|
_wopen->_wsopen_s_open,open->_sopen_s_wfopen->_wfopen_sfopen->fopen_s_wfreopen->_wfreopen_sfreopen->freopen_sFor better error handling and for using the CRT functions recommended
via warnings suppressed by
_CRT_SECURE_NO_WARNINGS.Also:
freopen_s()prototype when building with mingw-w64 <5.https://sourceforge.net/p/mingw-w64/mingw-w64/ci/a5d824654cdc57f6eac1bb581b078986f3eb6856/
open()in the signal handler with_sopen_s()on Windows.
Refs:
https://learn.microsoft.com/cpp/c-runtime-library/reference/open-wopen
https://learn.microsoft.com/cpp/c-runtime-library/reference/sopen-s-wsopen-s
https://learn.microsoft.com/cpp/c-runtime-library/reference/freopen-wfreopen
https://learn.microsoft.com/cpp/c-runtime-library/reference/fopen-wfopen
https://learn.microsoft.com/cpp/c-runtime-library/reference/fopen-s-wfopen-s
https://learn.microsoft.com/cpp/c-runtime-library/reference/freopen-s-wfreopen-s
freopen_swith mingw-w64 5+ only.lib/share.hto avoid collision with CRTshare.h. → lib: rename internal headershare.htocurl_share.hto avoid collision #19676#include <share.h>includeslib/share.hinstead ofshare.hfrom the CRT.Ref: lib: include files using known path #16991 that seemed fixing this issue reported in share.h conflicts with windows ucrt header #16949, but apparently this
use-case still hits it. Avoiding the name collision by renaming would be best?
fail, some others time out. → curl_fopen: do not pass invalid mode flags to
open()on Windows #19645Finalize the rough/quick fix, to try honoring
data->set.new_file_perms.Also split to separate PR. → file: do not pass invalid mode flags to
open()on upload (Windows) #19647Proposal: Bump required mingw-w64 version to 3.0 (from 1.0) #17984
open()on Windows #19645open()on upload (Windows) #19647open()(Windows) #19670open()mode flags #19671open()call withcurlx_open(). → tests/server: use curlx file open/close functions #19679fopen()call withcurlx_fopen(). → tests/server: use curlx file open/close functions #19679open()call with_svariant on Windows.