secure-transport: fix recv return code handling

Return code handling of recv calls were not always correct when an error
occured or the connection was closed.

Closes #10717
This commit is contained in:
Stefan Eissing 2023-03-09 11:55:46 +01:00 committed by Daniel Stenberg
parent 06f65f771b
commit 31889210b9
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -3377,13 +3377,15 @@ static ssize_t sectransp_recv(struct Curl_cfilter *cf,
DEBUGASSERT(backend);
again:
*curlcode = CURLE_OK;
err = SSLRead(backend->ssl_ctx, buf, buffersize, &processed);
if(err != noErr) {
switch(err) {
case errSSLWouldBlock: /* return how much we read (if anything) */
if(processed)
if(processed) {
return (ssize_t)processed;
}
*curlcode = CURLE_AGAIN;
return -1L;
break;
@ -3395,7 +3397,7 @@ static ssize_t sectransp_recv(struct Curl_cfilter *cf,
case errSSLClosedGraceful:
case errSSLClosedNoNotify:
*curlcode = CURLE_OK;
return -1L;
return 0;
break;
/* The below is errSSLPeerAuthCompleted; it's not defined in
@ -3406,8 +3408,10 @@ static ssize_t sectransp_recv(struct Curl_cfilter *cf,
CURLcode result = verify_cert(cf, data, conn_config->CAfile,
conn_config->ca_info_blob,
backend->ssl_ctx);
if(result)
return result;
if(result) {
*curlcode = result;
return -1;
}
}
goto again;
default: