Skip to content

Commit

Permalink
nss: implement data_pending method
Browse files Browse the repository at this point in the history
NSS currently uses the default Curl_none_data_pending() method which
always returns false, causing TLS buffered input data to be missed.

The current commit implements the nss_data_pending() method that properly
monitors the presence of available TLS data.

Ref:curl#10077
  • Loading branch information
monnerat committed Jan 5, 2023
1 parent becfe2e commit b8fe900
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/vtls/nss.c
Original file line number Diff line number Diff line change
Expand Up @@ -2404,6 +2404,20 @@ static ssize_t nss_send(struct Curl_cfilter *cf,
return rc; /* number of bytes */
}

static bool
nss_data_pending(struct Curl_cfilter *cf, const struct Curl_easy *data)
{
struct ssl_connect_data *connssl = cf->ctx;
PRFileDesc *fd = connssl->backend->handle->lower;
const PRRecvFN recv_fn = fd->methods->recv;
char buf;

(void) data;

/* Returns true in case of error to force reading. */
return recv_fn(fd, (void *) &buf, 1, PR_MSG_PEEK, PR_INTERVAL_NO_WAIT) != 0;;
}

static ssize_t nss_recv(struct Curl_cfilter *cf,
struct Curl_easy *data, /* transfer */
char *buf, /* store read data here */
Expand Down Expand Up @@ -2554,7 +2568,7 @@ const struct Curl_ssl Curl_ssl_nss = {
nss_check_cxn, /* check_cxn */
/* NSS has no shutdown function provided and thus always fail */
Curl_none_shutdown, /* shutdown */
Curl_none_data_pending, /* data_pending */
nss_data_pending, /* data_pending */
nss_random, /* random */
nss_cert_status_request, /* cert_status_request */
nss_connect, /* connect */
Expand Down

0 comments on commit b8fe900

Please sign in to comment.