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

@ -30,10 +30,6 @@
#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. */