mirror of
https://github.com/curl/curl.git
synced 2026-04-14 18:21:40 +03:00
tool_cb_hdr: use the file descriptor instead of calling fileno() again
Follow-up to 6041b9b11b
Closes #21126
This commit is contained in:
parent
ff678be69a
commit
d7d683c3ba
1 changed files with 5 additions and 7 deletions
|
|
@ -266,15 +266,13 @@ static size_t save_etag(const char *etag_h, const char *endp,
|
|||
curlx_struct_stat file;
|
||||
int fd = fileno(etag_save->stream);
|
||||
|
||||
/* Truncate regular files to avoid stale etag content */
|
||||
if((fd != -1) &&
|
||||
!curlx_fstat(fd, &file) &&
|
||||
(S_ISREG(file.st_mode))) {
|
||||
/*
|
||||
* Truncate regular files to avoid stale etag content.
|
||||
*/
|
||||
if(ftruncate(fileno(etag_save->stream), 0))
|
||||
return CURL_WRITEFUNC_ERROR;
|
||||
}
|
||||
(S_ISREG(file.st_mode) &&
|
||||
ftruncate(fd, 0)))
|
||||
return CURL_WRITEFUNC_ERROR;
|
||||
|
||||
fwrite(etag_h, 1, etag_length, etag_save->stream);
|
||||
/* terminate with newline */
|
||||
fputc('\n', etag_save->stream);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue