From: Viktor Szakats Date: Wed, 4 Feb 2026 13:32:11 +0000 (+0100) Subject: build: use native file open flags in Windows-specific code X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=462244447e8ba3a53b1ba9f0ba7baa52d8777daa;p=thirdparty%2Fcurl.git build: use native file open flags in Windows-specific code To comply with official documentation. Also to make code compile with `NO_OLDNAMES` (mingw-w64) or `_CRT_DECLARE_NONSTDC_NAMES=0` (MSVC) set. Ref: #15652 Closes #20516 --- diff --git a/.github/scripts/typos.toml b/.github/scripts/typos.toml index 04c8e90721..5e5a0346cf 100644 --- a/.github/scripts/typos.toml +++ b/.github/scripts/typos.toml @@ -11,7 +11,7 @@ extend-ignore-identifiers-re = [ "^0x[0-9a-fA-F]+FUL$", # unsigned long hex literals ending with 'F' "^(eyeballers|HELO_smtp|Januar|optin|passin|perfec|SMTP_HELO)$", "^(clen|req_clen|smtp_perform_helo|smtp_state_helo_resp|Tru64|_stati64)$", - "(ccontains|controllen|secur32)", + "(_ccontains|_controllen|O_WRONLY|secur32)", "proxys", # this should be limited to tests/http/*. Short for secure proxy. ] diff --git a/lib/curl_fopen.c b/lib/curl_fopen.c index d9cb3f73b8..b7a67aa565 100644 --- a/lib/curl_fopen.c +++ b/lib/curl_fopen.c @@ -125,8 +125,8 @@ CURLcode Curl_fopen(struct Curl_easy *data, const char *filename, result = CURLE_WRITE_ERROR; #ifdef _WIN32 - fd = curlx_open(tempstore, O_WRONLY | O_CREAT | O_EXCL, - S_IREAD | S_IWRITE); + fd = curlx_open(tempstore, _O_WRONLY | _O_CREAT | _O_EXCL, + _S_IREAD | _S_IWRITE); #elif (defined(ANDROID) || defined(__ANDROID__)) && \ (defined(__i386__) || defined(__arm__)) fd = curlx_open(tempstore, O_WRONLY | O_CREAT | O_EXCL, diff --git a/lib/curl_setup.h b/lib/curl_setup.h index 10cdb563d1..387dc57439 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -864,7 +864,9 @@ /* Since O_BINARY is used in bitmasks, setting it to zero makes it usable in source code but yet it does not ruin anything */ -#ifdef O_BINARY +#ifdef _O_BINARY /* for _WIN32 */ +#define CURL_O_BINARY _O_BINARY +#elif defined(O_BINARY) #define CURL_O_BINARY O_BINARY #else #define CURL_O_BINARY 0 diff --git a/src/tool_cb_wrt.c b/src/tool_cb_wrt.c index cc005844af..cfeb06d5a4 100644 --- a/src/tool_cb_wrt.c +++ b/src/tool_cb_wrt.c @@ -29,7 +29,7 @@ #include "tool_operate.h" #ifdef _WIN32 -#define OPENMODE S_IREAD | S_IWRITE +#define OPENMODE _S_IREAD | _S_IWRITE #else #define OPENMODE S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH #endif diff --git a/tests/server/tftpd.c b/tests/server/tftpd.c index 7b5a98958b..a15232deab 100644 --- a/tests/server/tftpd.c +++ b/tests/server/tftpd.c @@ -420,7 +420,7 @@ static ssize_t write_behind(struct testcase *test, int convert) snprintf(outfile, sizeof(outfile), "%s/upload.%ld", logdir, test->testno); test->ofile = curlx_open(outfile, O_CREAT | O_RDWR | CURL_O_BINARY, #ifdef _WIN32 - S_IREAD | S_IWRITE + _S_IREAD | _S_IWRITE #else S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | diff --git a/tests/server/util.c b/tests/server/util.c index 2719c8688d..2f7a8c8dae 100644 --- a/tests/server/util.c +++ b/tests/server/util.c @@ -333,8 +333,8 @@ static void exit_signal_handler(int signum) else { int fd = -1; #ifdef _WIN32 - if(!_sopen_s(&fd, serverlogfile, O_WRONLY | O_CREAT | O_APPEND, - _SH_DENYNO, S_IREAD | S_IWRITE) && + if(!_sopen_s(&fd, serverlogfile, _O_WRONLY | _O_CREAT | _O_APPEND, + _SH_DENYNO, _S_IREAD | _S_IWRITE) && fd != -1) { #else /* !checksrc! disable BANNEDFUNC 1 */