build: avoid overriding system open and stat symbols

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 10bac43b87 #18774
Follow-up to 20142f5d06 #18634
Follow-up to bf7375ecc5 #18503

Closes #18776
This commit is contained in:
Viktor Szakats 2025-09-30 01:27:10 +02:00
parent 684f4cdd3e
commit 9678ff5b1b
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
31 changed files with 76 additions and 83 deletions

View 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);

View 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);

View 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);

View 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);

View 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);

View 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;

View 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;

View 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);

View file

@ -3,6 +3,7 @@ allowfunc fclose
allowfunc fopen
allowfunc freeaddrinfo
allowfunc getaddrinfo
allowfunc open
allowfunc recv
allowfunc send
allowfunc socket

View 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);