Fix SSL_read error handling in http3 demo server

The SSL_read error handling misses the ZERO_RETURN clause which is
non-fatal, correct that.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26180)
This commit is contained in:
Neil Horman 2024-12-14 09:06:11 -05:00
parent 861a322400
commit eabdcadefa

View file

@ -86,7 +86,10 @@ static void init_ids(struct h3ssl *h3ssl)
int i;
char *prior_fileprefix = h3ssl->fileprefix;
memset (h3ssl, 0, sizeof (struct h3ssl));
if (h3ssl->ptr_data != NULL && h3ssl->ptr_data != nulldata)
free(h3ssl->ptr_data);
memset(h3ssl, 0, sizeof(struct h3ssl));
ssl_ids = h3ssl->ssl_ids;
for (i = 0; i < MAXSSL_IDS; i++) {
@ -348,9 +351,15 @@ static int quic_server_read(nghttp3_conn *h3conn, SSL *stream, uint64_t id, stru
fprintf(stderr, "SSL_read %d on %llu failed\n",
SSL_get_error(stream, ret),
(unsigned long long) id);
if (SSL_get_error(stream, ret) == SSL_ERROR_WANT_READ)
return 0; /* retry we need more data */
ERR_print_errors_fp(stderr);
switch (SSL_get_error(stream, ret)) {
case SSL_ERROR_WANT_READ:
return 0;
case SSL_ERROR_ZERO_RETURN:
return 1;
default:
ERR_print_errors_fp(stderr);
return -1;
}
return -1;
}