]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
build: avoid overriding system `open` and `stat` symbols
authorViktor Szakats <commit@vsz.me>
Mon, 29 Sep 2025 23:27:10 +0000 (01:27 +0200)
committerViktor Szakats <commit@vsz.me>
Tue, 30 Sep 2025 14:30:09 +0000 (16:30 +0200)
Replace them by `curlx_open()` and `curlx_stat()`.

To make it obvious in the source code what is being executed.

Also:
- tests/server: stop overriding `open()` for test servers.
  This is critical for the call made from the signal handler.
  For other calls, it's an option to use `curlx_open()`, but
  doesn't look important enough to do it, following the path
  taken with `fopen()`.

Follow-up to 10bac43b873fe45869e15b36aac1c1e5bc89b6e0 #18774
Follow-up to 20142f5d06f7120ba94cbcc25c998e8d81aec85b #18634
Follow-up to bf7375ecc50e857760b0d0a668c436e208a400bd #18503

Closes #18776

31 files changed:
docs/examples/.checksrc
docs/examples/anyauthput.c
docs/examples/fileupload.c
docs/examples/ftpupload.c
docs/examples/http2-upload.c
docs/examples/httpput.c
lib/config-win32.h
lib/curl_fopen.c
lib/curl_setup.h
lib/curlx/fopen.h
lib/file.c
lib/mime.c
lib/vquic/vquic.c
lib/vssh/libssh2.c
scripts/checksrc.pl
src/tool_cb_wrt.c
src/tool_doswin.c
src/tool_filetime.c
src/tool_findfile.c
src/tool_getpass.c
src/tool_operate.c
tests/libtest/lib505.c
tests/libtest/lib518.c
tests/libtest/lib525.c
tests/libtest/lib537.c
tests/libtest/lib541.c
tests/libtest/lib568.c
tests/libtest/lib572.c
tests/libtest/lib582.c
tests/server/.checksrc
tests/server/util.c

index e0b6c43da939c9a1e21915c726f5e5c5082489d7..259058cad5808c9bedf422d9cad6114a254aedec 100644 (file)
@@ -3,4 +3,5 @@ allowfunc fdopen
 allowfunc fopen
 allowfunc gmtime
 allowfunc localtime
+allowfunc open
 allowfunc socket
index c62250dce372c5cbdb0ee1d0c76ca02a3fefdc92..505d16b217b2744d004661415a1942f17a3164c1 100644 (file)
@@ -104,6 +104,7 @@ int main(int argc, char **argv)
     return 2;
 
 #ifdef UNDER_CE
+  /* !checksrc! disable BANNEDFUNC 1 */
   stat(file, &file_info);
 #else
   fstat(fileno(fp), &file_info);
index 0860c9457bea9d604e7318c6de881aecc6bd1049..29c3c3c3c138a813f878fec517c1c05c53f9f2ac 100644 (file)
@@ -52,6 +52,7 @@ int main(void)
 
   /* to get the file size */
 #ifdef UNDER_CE
+  /* !checksrc! disable BANNEDFUNC 1 */
   if(stat("debugit", &file_info) != 0) {
 #else
   if(fstat(fileno(fd), &file_info) != 0) {
index ec64f4a2cdd9bfff5115e5348bfca5e7bda84ea1..4f3b679226eb2d87c4e83e0344228acfa96efa1b 100644 (file)
@@ -96,6 +96,7 @@ int main(void)
 
   /* to get the file size */
 #ifdef UNDER_CE
+  /* !checksrc! disable BANNEDFUNC 1 */
   if(stat(LOCAL_FILE, &file_info) != 0) {
 #else
   if(fstat(fileno(hd_src), &file_info) != 0) {
index d13c5e58063cd7181f06f6bec896fbc949633456..b08e8fc102eb2d19197f427762d7a58085ebc124 100644 (file)
@@ -234,6 +234,7 @@ static int setup(struct input *i, int num, const char *upload)
   }
 
 #ifdef UNDER_CE
+  /* !checksrc! disable BANNEDFUNC 1 */
   if(stat(upload, &file_info) != 0) {
 #else
   if(fstat(fileno(i->in), &file_info) != 0) {
index ddb1b07328c6941c6b0f9de411b1534afeaae763..1951cb232e8ba2c073bbea4e6d57ebb21ccb74ac 100644 (file)
@@ -91,6 +91,7 @@ int main(int argc, char **argv)
 
   /* get the file size of the local file */
 #ifdef UNDER_CE
+  /* !checksrc! disable BANNEDFUNC 1 */
   if(stat(file, &file_info) != 0) {
 #else
   if(fstat(fileno(hd_src), &file_info) != 0) {
index b7f83927a43efdb7ca63f14d6b65248239e44c5b..408606d6117965432b4fde7a74dbf63b87325ab2 100644 (file)
 #define CURL_DISABLE_LDAP 1
 
 #ifndef _MSC_VER
+/* !checksrc! disable BANNEDFUNC 1 */
 extern int stat(const char *path, struct stat *buffer);
 #endif
 
index 13acd299c0ddc92e241d50761d5baa6cf720b6ed..5e25f0eab60e3e59379703e267adc7687e189915 100644 (file)
 #if !defined(CURL_DISABLE_COOKIES) || !defined(CURL_DISABLE_ALTSVC) ||  \
   !defined(CURL_DISABLE_HSTS)
 
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
 #include "urldata.h"
 #include "rand.h"
 #include "curl_fopen.h"
@@ -107,6 +103,7 @@ CURLcode Curl_fopen(struct Curl_easy *data, const char *filename,
     goto fail;
   if(
 #ifdef UNDER_CE
+     /* !checksrc! disable BANNEDFUNC 1 */
      stat(filename, &sb) == -1
 #else
      fstat(fileno(*fh), &sb) == -1
@@ -137,9 +134,11 @@ CURLcode Curl_fopen(struct Curl_easy *data, const char *filename,
   result = CURLE_WRITE_ERROR;
 #if (defined(ANDROID) || defined(__ANDROID__)) && \
   (defined(__i386__) || defined(__arm__))
-  fd = open(tempstore, O_WRONLY | O_CREAT | O_EXCL, (mode_t)(0600|sb.st_mode));
+  fd = curlx_open(tempstore, O_WRONLY | O_CREAT | O_EXCL,
+                  (mode_t)(0600 | sb.st_mode));
 #else
-  fd = open(tempstore, O_WRONLY | O_CREAT | O_EXCL, 0600|sb.st_mode);
+  fd = curlx_open(tempstore, O_WRONLY | O_CREAT | O_EXCL,
+                  0600 | sb.st_mode);
 #endif
   if(fd == -1)
     goto fail;
index b3c19a95efb53272b83bf908c5a34e015c8c2081..a741abde0323af56f1c1c565b52f0fdf2422d4a1 100644 (file)
 #    endif
 #    define LSEEK_ERROR                  (long)-1
 #  endif
-#  ifndef UNDER_CE
-     int curlx_win32_stat(const char *path, struct_stat *buffer);
-     int curlx_win32_open(const char *filename, int oflag, ...);
-#    define stat(fname, stp)           curlx_win32_stat(fname, stp)
-#    define open                       curlx_win32_open
-#  endif
 #elif defined(__DJGPP__)
    /* Requires DJGPP 2.04 */
 #  include <unistd.h>
index 2a2b079637892b38dd73e73d490143b10f70b720..d1e3d127c53dd8f4fa7af8d278ecfef5299f4843 100644 (file)
 
 #if defined(_WIN32) && !defined(UNDER_CE)
 FILE *curlx_win32_fopen(const char *filename, const char *mode);
+int curlx_win32_stat(const char *path, struct_stat *buffer);
+int curlx_win32_open(const char *filename, int oflag, ...);
 #define CURLX_FOPEN_LOW(fname, mode) curlx_win32_fopen(fname, mode)
+#define curlx_stat(fname, stp)       curlx_win32_stat(fname, stp)
+#define curlx_open                   curlx_win32_open
 #else
-#define CURLX_FOPEN_LOW fopen
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>  /* for open() */
+#endif
+#define CURLX_FOPEN_LOW              fopen
+#define curlx_stat(fname, stp)       stat(fname, stp)
+#define curlx_open                   open
 #endif
 
 #ifdef CURLDEBUG
-#define curlx_fopen(file,mode) curl_dbg_fopen(file,mode,__LINE__,__FILE__)
+#define curlx_fopen(file,mode)  curl_dbg_fopen(file,mode,__LINE__,__FILE__)
 #define curlx_fdopen(file,mode) curl_dbg_fdopen(file,mode,__LINE__,__FILE__)
-#define curlx_fclose(file) curl_dbg_fclose(file,__LINE__,__FILE__)
+#define curlx_fclose(file)      curl_dbg_fclose(file,__LINE__,__FILE__)
 #else
-#define curlx_fopen CURLX_FOPEN_LOW
-#define curlx_fdopen fdopen
-#define curlx_fclose fclose
+#define curlx_fopen             CURLX_FOPEN_LOW
+#define curlx_fdopen            fdopen
+#define curlx_fclose            fclose
 #endif
 
 #endif /* HEADER_CURLX_FOPEN_H */
index 749759653d5a6a63def81178b3fc558d07081eeb..2d5818a1db42cc02877b96a07babf2b95030bd3f 100644 (file)
 #include <sys/param.h>
 #endif
 
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
@@ -70,6 +66,7 @@
 #include "transfer.h"
 #include "url.h"
 #include "parsedate.h" /* for the week day and month names */
+#include "curlx/fopen.h"
 #include "curlx/warnless.h"
 #include "curl_range.h"
 /* The last 3 #include files should be in this order */
@@ -237,7 +234,7 @@ static CURLcode file_connect(struct Curl_easy *data, bool *done)
       return CURLE_URL_MALFORMAT;
     }
 
-  fd = open(actual_path, O_RDONLY|CURL_O_BINARY);
+  fd = curlx_open(actual_path, O_RDONLY | CURL_O_BINARY);
   file->path = actual_path;
 #else
   if(memchr(real_path, 0, real_path_len)) {
@@ -261,16 +258,16 @@ static CURLcode file_connect(struct Curl_easy *data, bool *done)
     extern int __unix_path_semantics;
     if(strchr(real_path + 1, ':')) {
       /* Amiga absolute path */
-      fd = open(real_path + 1, O_RDONLY);
+      fd = curlx_open(real_path + 1, O_RDONLY);
       file->path++;
     }
     else if(__unix_path_semantics) {
       /* -lunix fallback */
-      fd = open(real_path, O_RDONLY);
+      fd = curlx_open(real_path, O_RDONLY);
     }
   }
   #else
-  fd = open(real_path, O_RDONLY);
+  fd = curlx_open(real_path, O_RDONLY);
   file->path = real_path;
   #endif
 #endif
@@ -349,9 +346,9 @@ static CURLcode file_upload(struct Curl_easy *data,
 
 #if (defined(ANDROID) || defined(__ANDROID__)) && \
   (defined(__i386__) || defined(__arm__))
-  fd = open(file->path, mode, (mode_t)data->set.new_file_perms);
+  fd = curlx_open(file->path, mode, (mode_t)data->set.new_file_perms);
 #else
-  fd = open(file->path, mode, data->set.new_file_perms);
+  fd = curlx_open(file->path, mode, data->set.new_file_perms);
 #endif
   if(fd < 0) {
     failf(data, "cannot open %s for writing", file->path);
index 6ec7f6904671c706bfaf784cda48132e00f72221..fe632604ed9d41dd339640b235455690c8fe2857 100644 (file)
@@ -205,7 +205,7 @@ static FILE * vmsfopenread(const char *file, const char *mode)
   struct_stat statbuf;
   int result;
 
-  result = stat(file, &statbuf);
+  result = curlx_stat(file, &statbuf);
 
   switch(statbuf.st_fab_rfm) {
   case FAB$C_VAR:
@@ -1412,7 +1412,7 @@ CURLcode curl_mime_filedata(curl_mimepart *part, const char *filename)
     char *base;
     struct_stat sbuf;
 
-    if(stat(filename, &sbuf))
+    if(curlx_stat(filename, &sbuf))
       result = CURLE_READ_ERROR;
     else {
       part->data = strdup(filename);
index 47fbf63af05a055f3607d1c24d23655f95447e4b..c50981975211a0806985851cd86f9678ea29fe4c 100644 (file)
 #ifdef HAVE_NETINET_UDP_H
 #include <netinet/udp.h>
 #endif
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
 #ifdef USE_NGHTTP3
 #include <nghttp3/nghttp3.h>
 #endif
 #include "../urldata.h"
 #include "../bufq.h"
 #include "../curlx/dynbuf.h"
+#include "../curlx/fopen.h"
 #include "../cfilters.h"
 #include "../curl_trc.h"
 #include "curl_ngtcp2.h"
@@ -665,8 +663,9 @@ CURLcode Curl_qlogdir(struct Curl_easy *data,
       result = curlx_dyn_add(&fname, ".sqlog");
 
     if(!result) {
-      int qlogfd = open(curlx_dyn_ptr(&fname), O_WRONLY|O_CREAT|CURL_O_BINARY,
-                        data->set.new_file_perms);
+      int qlogfd = curlx_open(curlx_dyn_ptr(&fname),
+                              O_WRONLY | O_CREAT | CURL_O_BINARY,
+                              data->set.new_file_perms);
       if(qlogfd != -1)
         *qlogfdp = qlogfd;
     }
index f68e3ee168f84c13df8f4afec75eaddce06a0bd9..0b82b568b13a8fdd9ce2c156a1911c7de6d25edb 100644 (file)
 
 #include <limits.h>
 
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
 #ifdef HAVE_NETINET_IN_H
 #include <netinet/in.h>
 #endif
@@ -68,6 +64,7 @@
 #include "../sockaddr.h" /* required for Curl_sockaddr_storage */
 #include "../multiif.h"
 #include "../select.h"
+#include "../curlx/fopen.h"
 #include "../curlx/warnless.h"
 #include "curl_path.h"
 #include "../curlx/strparse.h"
@@ -1199,12 +1196,12 @@ static CURLcode ssh_state_pkey_init(struct Curl_easy *data,
         sshc->rsa = aprintf("%s/.ssh/id_rsa", home);
         if(!sshc->rsa)
           out_of_memory = TRUE;
-        else if(stat(sshc->rsa, &sbuf)) {
+        else if(curlx_stat(sshc->rsa, &sbuf)) {
           free(sshc->rsa);
           sshc->rsa = aprintf("%s/.ssh/id_dsa", home);
           if(!sshc->rsa)
             out_of_memory = TRUE;
-          else if(stat(sshc->rsa, &sbuf)) {
+          else if(curlx_stat(sshc->rsa, &sbuf)) {
             Curl_safefree(sshc->rsa);
           }
         }
@@ -1213,10 +1210,10 @@ static CURLcode ssh_state_pkey_init(struct Curl_easy *data,
       if(!out_of_memory && !sshc->rsa) {
         /* Nothing found; try the current dir. */
         sshc->rsa = strdup("id_rsa");
-        if(sshc->rsa && stat(sshc->rsa, &sbuf)) {
+        if(sshc->rsa && curlx_stat(sshc->rsa, &sbuf)) {
           free(sshc->rsa);
           sshc->rsa = strdup("id_dsa");
-          if(sshc->rsa && stat(sshc->rsa, &sbuf)) {
+          if(sshc->rsa && curlx_stat(sshc->rsa, &sbuf)) {
             free(sshc->rsa);
             /* Out of guesses. Set to the empty string to avoid
              * surprising info messages. */
index 5e8434d5fabfc6ca74d21945b1edd15f22748fcb..0907c3f9ad4ca2a50ef0b4916f0e038064237118 100755 (executable)
@@ -91,6 +91,8 @@ my %banfunc = (
     "fclose" => 1,
     "fdopen" => 1,
     "fopen" => 1,
+    "open" => 1,
+    "stat" => 1,
     );
 
 my %warnings_extended = (
index b4ea781739a7e765dc626a50f6cfba4667cfefca..12e4417da47919896e8e645cde4371ca952aeb24 100644 (file)
  ***************************************************************************/
 #include "tool_setup.h"
 
-#ifdef HAVE_FCNTL_H
-/* for open() */
-#include <fcntl.h>
-#endif
-
 #include "tool_cfgable.h"
 #include "tool_msgs.h"
 #include "tool_cb_wrt.h"
@@ -60,7 +55,8 @@ bool tool_create_output_file(struct OutStruct *outs,
   else {
     int fd;
     do {
-      fd = open(fname, O_CREAT | O_WRONLY | O_EXCL | CURL_O_BINARY, OPENMODE);
+      fd = curlx_open(fname, O_CREAT | O_WRONLY | O_EXCL | CURL_O_BINARY,
+                      OPENMODE);
       /* Keep retrying in the hope that it is not interrupted sometime */
       /* !checksrc! disable ERRNOVAR 1 */
     } while(fd == -1 && errno == EINTR);
@@ -78,8 +74,9 @@ bool tool_create_output_file(struct OutStruct *outs,
           return FALSE;
         next_num++;
         do {
-          fd = open(curlx_dyn_ptr(&fbuffer),
-                    O_CREAT | O_WRONLY | O_EXCL | CURL_O_BINARY, OPENMODE);
+          fd = curlx_open(curlx_dyn_ptr(&fbuffer),
+                          O_CREAT | O_WRONLY | O_EXCL | CURL_O_BINARY,
+                          OPENMODE);
           /* Keep retrying in the hope that it is not interrupted sometime */
         } while(fd == -1 && errno == EINTR);
       }
index 29f8cecbd799838b42d136c522d6a822be0e6a3c..51b6f341018a6f259ad97806ab17c617ca297a49 100644 (file)
@@ -532,7 +532,7 @@ static SANITIZEcode rename_if_reserved_dos(char **const sanitized,
      identify whether it is a reserved device name and not a regular
      filename. */
 #ifdef MSDOS
-  if(base && ((stat(base, &st_buf)) == 0) && (S_ISCHR(st_buf.st_mode))) {
+  if(base && (curlx_stat(base, &st_buf) == 0) && S_ISCHR(st_buf.st_mode)) {
     /* Prepend a '_' */
     size_t blen = strlen(base);
     if(blen) {
index c818fe3ada200df44718597e9460a3335981aa40..5912a5aa9a521b5826ff16a300619493fc1339d0 100644 (file)
@@ -75,7 +75,7 @@ int getfiletime(const char *filename, curl_off_t *stamp)
   }
 #else
   struct_stat statbuf;
-  if(stat(filename, &statbuf) != -1) {
+  if(curlx_stat(filename, &statbuf) != -1) {
     *stamp = (curl_off_t)statbuf.st_mtime;
     rc = 0;
   }
index 8b2be841421438b90a23486347ef5df35e80ea64..7705ab7d926f32511eff1f6cb398f94412989ef6 100644 (file)
 #endif
 #endif
 
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
 #include "tool_findfile.h"
 #include "tool_cfgable.h"
 
@@ -77,7 +73,7 @@ static char *checkhome(const char *home, const char *fname, bool dotscore)
     else
       c = aprintf("%s" DIR_CHAR "%s", home, fname);
     if(c) {
-      int fd = open(c, O_RDONLY);
+      int fd = curlx_open(c, O_RDONLY);
       if(fd >= 0) {
         char *path = strdup(c);
         close(fd);
index fc59accc07acd476ac349b73580654468593a362..a92fb7594c78bf83edefee1daefbe7b07b331f4f 100644 (file)
 #ifndef HAVE_GETPASS_R
 /* this file is only for systems without getpass_r() */
 
-#ifdef HAVE_FCNTL_H
-#  include <fcntl.h>
-#endif
-
 #ifdef HAVE_TERMIOS_H
 #  include <termios.h>
 #elif defined(HAVE_TERMIO_H)
@@ -178,7 +174,7 @@ char *getpass_r(const char *prompt, /* prompt to display */
 {
   ssize_t nread;
   bool disabled;
-  int fd = open("/dev/tty", O_RDONLY);
+  int fd = curlx_open("/dev/tty", O_RDONLY);
   if(fd == -1)
     fd = STDIN_FILENO; /* use stdin if the tty could not be used */
 
index d5a1b2646812482e5e8ac7da34f03ce83756775d..d4a6d4db42512248f85fd13d8f79a7ee24e0832b 100644 (file)
  ***************************************************************************/
 #include "tool_setup.h"
 
-#ifdef HAVE_FCNTL_H
-#  include <fcntl.h>
-#endif
-
 #ifdef HAVE_LOCALE_H
 #  include <locale.h>
 #endif
@@ -279,22 +275,22 @@ static CURLcode pre_transfer(struct per_transfer *per)
 #ifdef __VMS
     /* Calculate the real upload size for VMS */
     per->infd = -1;
-    if(stat(per->uploadfile, &fileinfo) == 0) {
+    if(curlx_stat(per->uploadfile, &fileinfo) == 0) {
       fileinfo.st_size = VmsSpecialSize(uploadfile, &fileinfo);
       switch(fileinfo.st_fab_rfm) {
       case FAB$C_VAR:
       case FAB$C_VFC:
       case FAB$C_STMCR:
-        per->infd = open(per->uploadfile, O_RDONLY | CURL_O_BINARY);
+        per->infd = curlx_open(per->uploadfile, O_RDONLY | CURL_O_BINARY);
         break;
       default:
-        per->infd = open(per->uploadfile, O_RDONLY | CURL_O_BINARY,
-                         "rfm=stmlf", "ctx=stm");
+        per->infd = curlx_open(per->uploadfile, O_RDONLY | CURL_O_BINARY,
+                               "rfm=stmlf", "ctx=stm");
       }
     }
     if(per->infd == -1)
 #else
-      per->infd = open(per->uploadfile, O_RDONLY | CURL_O_BINARY);
+      per->infd = curlx_open(per->uploadfile, O_RDONLY | CURL_O_BINARY);
     if((per->infd == -1) || fstat(per->infd, &fileinfo))
 #endif
     {
@@ -668,8 +664,7 @@ static CURLcode post_per_transfer(struct per_transfer *per,
     }
     if(result && config->rm_partial) {
       struct_stat st;
-      if(!stat(outs->filename, &st) &&
-         S_ISREG(st.st_mode)) {
+      if(!curlx_stat(outs->filename, &st) && S_ISREG(st.st_mode)) {
         if(!unlink(outs->filename))
           notef("Removed output file: %s", outs->filename);
         else
@@ -974,7 +969,7 @@ static CURLcode setup_outfile(struct OperationConfig *config,
 
   if(config->skip_existing) {
     struct_stat fileinfo;
-    if(!stat(per->outfile, &fileinfo)) {
+    if(!curlx_stat(per->outfile, &fileinfo)) {
       /* file is present */
       notef("skips transfer, \"%s\" exists locally", per->outfile);
       per->skip = TRUE;
@@ -987,7 +982,7 @@ static CURLcode setup_outfile(struct OperationConfig *config,
        of the file as it is now and open it for append instead */
     struct_stat fileinfo;
     /* VMS -- Danger, the filesize is only valid for stream files */
-    if(stat(per->outfile, &fileinfo) == 0)
+    if(curlx_stat(per->outfile, &fileinfo) == 0)
       /* set offset to current file size: */
       config->resume_from = fileinfo.st_size;
     else
index fc200945847e83cc71a2c5783ba025a945f133ae..71b79b2a244ef13e34de0f9a8a57c1063d416d18 100644 (file)
@@ -61,6 +61,7 @@ static CURLcode test_lib505(const char *URL)
 
   /* get the file size of the local file */
 #ifdef UNDER_CE
+  /* !checksrc! disable BANNEDFUNC 1 */
   hd = stat(libtest_arg2, &file_info);
 #else
   hd = fstat(fileno(hd_src), &file_info);
index 9cf3a42554ad40116e8c943c46ed492f1c8cf06d..007d26187012efdbde1d8d270a9d42465de970f0 100644 (file)
@@ -287,7 +287,7 @@ static int t518_test_rlimit(int keep_open)
 
   /* open a dummy descriptor */
 
-  t518_testfd[0] = open(DEV_NULL, O_RDONLY);
+  t518_testfd[0] = curlx_open(DEV_NULL, O_RDONLY);
   if(t518_testfd[0] < 0) {
     curl_msnprintf(strbuff, sizeof(strbuff), "opening of %s failed", DEV_NULL);
     t518_store_errmsg(strbuff, errno);
index 007889fdc722b4b3aa8e5845c9dc1621ea29dc51..b34cd261af2697dbae6a5d73b6fa8da26d7d8f02 100644 (file)
@@ -52,6 +52,7 @@ static CURLcode test_lib525(const char *URL)
 
   /* get the file size of the local file */
 #ifdef UNDER_CE
+  /* !checksrc! disable BANNEDFUNC 1 */
   hd = stat(libtest_arg2, &file_info);
 #else
   hd = fstat(fileno(hd_src), &file_info);
index 90de8a2d0c7596afa546bd7db0f8ade2795dd885..b8bbfb7536c3784d660ce7cee751981e1302130d 100644 (file)
@@ -289,7 +289,7 @@ static int t537_test_rlimit(int keep_open)
 
   /* open a dummy descriptor */
 
-  t537_testfd[0] = open(DEV_NULL, O_RDONLY);
+  t537_testfd[0] = curlx_open(DEV_NULL, O_RDONLY);
   if(t537_testfd[0] < 0) {
     curl_msnprintf(strbuff, sizeof(strbuff), "opening of %s failed", DEV_NULL);
     t537_store_errmsg(strbuff, errno);
index 3bb64f8ac4a415aa26836da13e89e1fbb77d2d30..5e6e3c2f333b9e1a0b8e91de65b04dffa9d2002a 100644 (file)
@@ -52,6 +52,7 @@ static CURLcode test_lib541(const char *URL)
 
   /* get the file size of the local file */
 #ifdef UNDER_CE
+  /* !checksrc! disable BANNEDFUNC 1 */
   hd = stat(libtest_arg2, &file_info);
 #else
   hd = fstat(fileno(hd_src), &file_info);
index 83c6fd23941c51218c3284fd0ea3f3b78a66a59d..6e53b79989567d6460d449b8f71eb677d76665fc 100644 (file)
@@ -66,7 +66,7 @@ static CURLcode test_lib568(const char *URL)
   curl_free(stream_uri);
   stream_uri = NULL;
 
-  sdp = open(libtest_arg2, O_RDONLY);
+  sdp = curlx_open(libtest_arg2, O_RDONLY);
   if(sdp == -1) {
     curl_mfprintf(stderr, "can't open %s\n", libtest_arg2);
     res = TEST_ERR_MAJOR_BAD;
index ef5e0660235750da00fda91c4a95a7d95a480cb0..c3951f8d1df6145614270a909b9f4ad858b4a29c 100644 (file)
@@ -84,7 +84,7 @@ static CURLcode test_lib572(const char *URL)
   stream_uri = NULL;
 
   /* PUT style GET_PARAMETERS */
-  params = open(libtest_arg2, O_RDONLY);
+  params = curlx_open(libtest_arg2, O_RDONLY);
   if(params == -1) {
     curl_mfprintf(stderr, "can't open %s\n", libtest_arg2);
     res = TEST_ERR_MAJOR_BAD;
index b1970632210d18f8f8da4add774675207ebb0d8c..9671c4b52f669313524c5ae0edeabecabd13ae3a 100644 (file)
@@ -253,6 +253,7 @@ static CURLcode test_lib582(const char *URL)
 
   /* get the file size of the local file */
 #ifdef UNDER_CE
+  /* !checksrc! disable BANNEDFUNC 1 */
   hd = stat(libtest_arg2, &file_info);
 #else
   hd = fstat(fileno(hd_src), &file_info);
index 670d4b800912febc0fe374db76e5a9f4a35d2daf..29331433c2cb8fda080057d4bfbc04a33636992e 100644 (file)
@@ -3,6 +3,7 @@ allowfunc fclose
 allowfunc fopen
 allowfunc freeaddrinfo
 allowfunc getaddrinfo
+allowfunc open
 allowfunc recv
 allowfunc send
 allowfunc socket
index 41f42ca42e09dbc10755fd5a35133349024e9d5a..749e33003c29b7009e4eae57da6fd6ca42794c85 100644 (file)
@@ -373,12 +373,12 @@ static void exit_signal_handler(int signum)
     (void)!write(STDERR_FILENO, msg, sizeof(msg) - 1);
   }
   else {
-    int fd;
 #ifdef _WIN32
-    fd = _open(serverlogfile, O_WRONLY|O_CREAT|O_APPEND, S_IREAD | S_IWRITE);
+#define OPENMODE S_IREAD | S_IWRITE
 #else
-    fd = open(serverlogfile, O_WRONLY|O_CREAT|O_APPEND, S_IRUSR | S_IWUSR);
+#define OPENMODE S_IRUSR | S_IWUSR
 #endif
+    int fd = open(serverlogfile, O_WRONLY | O_CREAT | O_APPEND, OPENMODE);
     if(fd != -1) {
       static const char msg[] = "exit_signal_handler: called\n";
       (void)!write(fd, msg, sizeof(msg) - 1);