summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Landau <hlandau@openssl.org>2024-03-29 14:51:35 +0000
committerTomas Mraz <tomas@openssl.org>2024-04-10 15:50:58 +0200
commitf43f1fadbfc5a45463766527f38310df8e3d28be (patch)
tree5d2c1059eadb316856569369f81478262758f440
parent1d4174b4130ccbcb7ee3c6dbcff614bd4f19b7a6 (diff)
Change approach to SSL_pending API
Reviewed-by: Neil Horman <nhorman@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/24039)
-rw-r--r--include/internal/quic_stream_map.h11
-rw-r--r--ssl/quic/quic_impl.c11
2 files changed, 15 insertions, 7 deletions
diff --git a/include/internal/quic_stream_map.h b/include/internal/quic_stream_map.h
index 30ae1e5f98..8f551f45d6 100644
--- a/include/internal/quic_stream_map.h
+++ b/include/internal/quic_stream_map.h
@@ -504,10 +504,11 @@ static ossl_inline ossl_unused int ossl_quic_stream_recv_get_final_size(const QU
}
/*
- * Determines the number of bytes available still to be read, and whether a FIN
- * has yet to be read.
+ * Determines the number of bytes available still to be read, and (if
+ * include_fin is 1) whether a FIN or reset has yet to be read.
*/
-static ossl_inline ossl_unused int ossl_quic_stream_recv_pending(const QUIC_STREAM *s)
+static ossl_inline ossl_unused int ossl_quic_stream_recv_pending(const QUIC_STREAM *s,
+ int include_fin)
{
size_t avail;
int fin = 0;
@@ -523,13 +524,13 @@ static ossl_inline ossl_unused int ossl_quic_stream_recv_pending(const QUIC_STRE
if (!ossl_quic_rstream_available(s->rstream, &avail, &fin))
avail = 0;
- if (avail == 0 && fin)
+ if (avail == 0 && include_fin && fin)
avail = 1;
return avail;
case QUIC_RSTREAM_STATE_RESET_RECVD:
- return 1;
+ return include_fin;
case QUIC_RSTREAM_STATE_DATA_READ:
case QUIC_RSTREAM_STATE_RESET_READ:
diff --git a/ssl/quic/quic_impl.c b/ssl/quic/quic_impl.c
index 3add9542ef..13d929b926 100644
--- a/ssl/quic/quic_impl.c
+++ b/ssl/quic/quic_impl.c
@@ -2441,6 +2441,11 @@ static int quic_write_nonblocking_epw(QCTX *ctx, const void *buf, size_t len,
}
quic_post_write(xso, *written > 0, 1);
+
+ if (*written == 0)
+ /* SSL_write_ex returns 0 if it didn't read anything .*/
+ return QUIC_RAISE_NORMAL_ERROR(ctx, SSL_ERROR_WANT_READ);
+
return 1;
}
@@ -2823,11 +2828,13 @@ static size_t ossl_quic_pending_int(const SSL *s, int check_channel)
}
if (check_channel)
- avail = ossl_quic_stream_recv_pending(ctx.xso->stream)
+ avail = ossl_quic_stream_recv_pending(ctx.xso->stream,
+ /*include_fin=*/1)
|| ossl_quic_channel_has_pending(ctx.qc->ch)
|| ossl_quic_channel_is_term_any(ctx.qc->ch);
else
- avail = ossl_quic_stream_recv_pending(ctx.xso->stream);
+ avail = ossl_quic_stream_recv_pending(ctx.xso->stream,
+ /*include_fin=*/0);
out:
quic_unlock(ctx.qc);