mirror of
https://github.com/curl/curl.git
synced 2026-08-01 10:08:04 +03:00
mbedtls: return error when retrying a blocked send with a shorter buffer
mbedtls_ssl_write() requires the retry call after WANT_WRITE to use at least as many bytes as the original blocked call. The DEBUGASSERT enforcing this was compiled out in release builds, leaving the len inflation free to exceed the caller's buffer and produce n > buflen. Replace the assert with an explicit CURLE_SEND_ERROR so the constraint is enforced in release builds too. Document the retry buflen requirement in curl_easy_send(3).
This commit is contained in:
parent
f76f79696e
commit
4a999def99
2 changed files with 5 additions and 2 deletions
|
|
@ -92,7 +92,9 @@ send.
|
|||
On failure, returns the appropriate error code.
|
||||
|
||||
This function may return **CURLE_AGAIN**. In this case, use your operating
|
||||
system facilities to wait until the socket is writable, and retry.
|
||||
system facilities to wait until the socket is writable, and retry. The
|
||||
**buflen** passed to the retry should be no smaller than the one passed to
|
||||
the call that returned **CURLE_AGAIN**.
|
||||
|
||||
If there is no socket available to use from the previous transfer, this
|
||||
function returns **CURLE_UNSUPPORTED_PROTOCOL**.
|
||||
|
|
|
|||
|
|
@ -1280,7 +1280,8 @@ static CURLcode mbed_send(struct Curl_cfilter *cf, struct Curl_easy *data,
|
|||
* loses bytes, e.g. reporting all was sent but they were not.
|
||||
* Remember the blocked length and use that when set. */
|
||||
if(backend->send_blocked) {
|
||||
DEBUGASSERT(backend->send_blocked_len <= len);
|
||||
if(len < backend->send_blocked_len)
|
||||
return CURLE_SEND_ERROR;
|
||||
CURL_TRC_CF(data, cf, "mbedtls_ssl_write(len=%zu) -> previously blocked "
|
||||
"on %zu bytes", len, backend->send_blocked_len);
|
||||
len = backend->send_blocked_len;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue