]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix SSL_read error handling in http3 demo server
authorNeil Horman <nhorman@openssl.org>
Sat, 14 Dec 2024 14:06:11 +0000 (09:06 -0500)
committerNeil Horman <nhorman@openssl.org>
Mon, 17 Feb 2025 16:27:33 +0000 (11:27 -0500)
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)

demos/http3/ossl-nghttp3-demo-server.c

index 2541d78d369f327a7bfe02eef2a4a3e6a0966f9e..1e89baee129f99be09bf0d11697e9b214b0e55f0 100644 (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;
     }