The vulnerability (CVE-2023-28322) occurs when a cURL handle is reused: first for a PUT request with a read callback (CURLOPT_READFUNCTION), and then for a POST request with CURLOPT_POSTFIELDS. Libcurl would erroneously use the old read callback for the POST request.
The primary fix is in Curl_vsetopt (in lib/url.c). When CURLOPT_POSTFIELDS is set, the code now checks if the handle was previously used for a PUT with a read callback (data->state.upload_from_put). If so, it explicitly clears the read callback function pointer (data->state.fread_func) and its associated input pointer (data->state.in). This prevents the stale callback from being used.
Curl_fillreadbuffer (in lib/sendf.c) is the function that actually invokes the fread_func. While not patched itself for this CVE, it's the component that would perform the erroneous action (calling the stale callback) if the state managed by Curl_vsetopt was incorrect. Therefore, it's a runtime indicator of where the faulty logic would manifest. The user-provided read callback function would also appear in stack traces, invoked by Curl_fillreadbuffer.
The analysis is based on the commit 091323241edd7339a37393f68777a4a1519e1859 from the curl/curl repository, which addresses CVE-2023-28322, as identified from PR #10949.