summaryrefslogtreecommitdiff
path: root/libs/libcurl/src/fopen.c
diff options
context:
space:
mode:
authordartraiden <wowemuh@gmail.com>2023-07-20 15:51:36 +0300
committerdartraiden <wowemuh@gmail.com>2023-07-20 16:02:00 +0300
commit1bec902c5a0b0161158aff935761dcb5754697d4 (patch)
treed97807c76c8a32b1dc9653655a34c8480d17fedb /libs/libcurl/src/fopen.c
parentf7e76bcda435d7ca6f6c8f9d78ceba5ad2066d16 (diff)
libcurl: update to 8.2.0
Diffstat (limited to 'libs/libcurl/src/fopen.c')
-rw-r--r--libs/libcurl/src/fopen.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/libs/libcurl/src/fopen.c b/libs/libcurl/src/fopen.c
index 0e9b704a7c..60dd1e18c4 100644
--- a/libs/libcurl/src/fopen.c
+++ b/libs/libcurl/src/fopen.c
@@ -56,13 +56,13 @@ CURLcode Curl_fopen(struct Curl_easy *data, const char *filename,
int fd = -1;
*tempname = NULL;
- if(stat(filename, &sb) == -1 || !S_ISREG(sb.st_mode)) {
- /* a non-regular file, fallback to direct fopen() */
- *fh = fopen(filename, FOPEN_WRITETEXT);
- if(*fh)
- return CURLE_OK;
+ *fh = fopen(filename, FOPEN_WRITETEXT);
+ if(!*fh)
goto fail;
- }
+ if(fstat(fileno(*fh), &sb) == -1 || !S_ISREG(sb.st_mode))
+ return CURLE_OK;
+ fclose(*fh);
+ *fh = NULL;
result = Curl_rand_hex(data, randsuffix, sizeof(randsuffix));
if(result)
@@ -85,7 +85,7 @@ CURLcode Curl_fopen(struct Curl_easy *data, const char *filename,
if((fstat(fd, &nsb) != -1) &&
(nsb.st_uid == sb.st_uid) && (nsb.st_gid == sb.st_gid)) {
/* if the user and group are the same, clone the original mode */
- if(fchmod(fd, sb.st_mode) == -1)
+ if(fchmod(fd, (mode_t)sb.st_mode) == -1)
goto fail;
}
}