]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
build: use native file open flags in Windows-specific code
authorViktor Szakats <commit@vsz.me>
Wed, 4 Feb 2026 13:32:11 +0000 (14:32 +0100)
committerViktor Szakats <commit@vsz.me>
Wed, 4 Feb 2026 14:59:35 +0000 (15:59 +0100)
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

.github/scripts/typos.toml
lib/curl_fopen.c
lib/curl_setup.h
src/tool_cb_wrt.c
tests/server/tftpd.c
tests/server/util.c

index 04c8e9072177183d268b9881fd18f2854aa3c865..5e5a0346cfdc3b60e26137cbe06edb244f82f186 100644 (file)
@@ -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.
 ]
 
index d9cb3f73b816ce7c1f12cb7c83c866a0e45c94aa..b7a67aa565cceefa82610322efe74980465ca30a 100644 (file)
@@ -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,
index 10cdb563d11b4ef2b0c3037d13ae91bf7b5d4db2..387dc57439d7fc0e478b2f86dc0d64e20cd822f9 100644 (file)
 
 /* 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
index cc005844af068d4ba35c90e9bbf41a86a6c4afcc..cfeb06d5a47539c94fb2aa9ad85ed0a6da285cae 100644 (file)
@@ -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
index 7b5a98958bccda6b0a9b5e0c5acbfb86d4b0c61a..a15232deabdc92ed2226f9ebded0a207d63dd5de 100644 (file)
@@ -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 |
index 2719c8688df6e8719c94a7647f59ca2970b54b6d..2f7a8c8dae99ec376f9d4496a4cdc40943a9a23e 100644 (file)
@@ -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 */