tool_cb_hdr: return error for failed header writes

By checking that fflush() works.

Reported-by: Sebastian Andersson
Fixes #13836
Closes #13859
This commit is contained in:
Daniel Stenberg 2024-06-02 17:16:58 +02:00
parent 464282ddfb
commit c61f753881
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -105,7 +105,11 @@ size_t tool_header_cb(char *ptr, size_t size, size_t nmemb, void *userdata)
if(rc != cb)
return rc;
/* flush the stream to send off what we got earlier */
(void)fflush(heads->stream);
if(fflush(heads->stream)) {
errorf(per->config->global, "Failed writing headers to %s",
per->config->headerfile);
return CURL_WRITEFUNC_ERROR;
}
}
curl_easy_getinfo(per->curl, CURLINFO_SCHEME, &scheme);