tool_cb_hdr: size is always 1

- add comment in the header that the argument 'size' is always 1,
  as guaranteed by the libcurl API

- then fix the call to fwrite() to avoid using "size, etag_length" which
  would be wrong if size was something else than 1, and use a fixed
  number there instead.

Reported in Joshua's sarif data

Closes #18630
This commit is contained in:
Daniel Stenberg 2025-09-20 11:31:54 +02:00
parent 335d16e944
commit 0209e087c6
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -81,6 +81,8 @@ fail:
/*
** callback for CURLOPT_HEADERFUNCTION
*
* 'size' is always 1
*/
size_t tool_header_cb(char *ptr, size_t size, size_t nmemb, void *userdata)
{
@ -164,7 +166,7 @@ size_t tool_header_cb(char *ptr, size_t size, size_t nmemb, void *userdata)
}
#endif
fwrite(etag_h, size, etag_length, etag_save->stream);
fwrite(etag_h, 1, etag_length, etag_save->stream);
/* terminate with newline */
fputc('\n', etag_save->stream);
(void)fflush(etag_save->stream);