mirror of
https://github.com/curl/curl.git
synced 2026-08-25 17:43:39 +03:00
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 to10bac43b87#18774 Follow-up to20142f5d06#18634 Follow-up tobf7375ecc5#18503 Closes #18776
This commit is contained in:
parent
684f4cdd3e
commit
9678ff5b1b
31 changed files with 76 additions and 83 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ allowfunc fclose
|
|||
allowfunc fopen
|
||||
allowfunc freeaddrinfo
|
||||
allowfunc getaddrinfo
|
||||
allowfunc open
|
||||
allowfunc recv
|
||||
allowfunc send
|
||||
allowfunc socket
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue