]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
http_client.c: fix error and default case handling in OSSL_HTTP_REQ_CTX_nbio() state...
authorDr. David von Oheimb <dev@ddvo.net>
Wed, 15 Jan 2025 17:12:22 +0000 (18:12 +0100)
committerDr. David von Oheimb <dev@ddvo.net>
Tue, 11 Feb 2025 21:11:03 +0000 (22:11 +0100)
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25541)

crypto/http/http_client.c

index 95dabc8ec54d5cdef511b093b60612eea03fe6f3..d3cc070d61cbbecdf2e26ab25c4014fd63beaeba 100644 (file)
@@ -603,6 +603,10 @@ int OSSL_HTTP_REQ_CTX_nbio(OSSL_HTTP_REQ_CTX *rctx)
     }
 
     switch (rctx->state) {
+    case OHS_ERROR:
+    default:
+        return 0;
+
     case OHS_ADD_HEADERS:
         /* Last operation was adding headers: need a final \r\n */
         if (BIO_write(rctx->mem, "\r\n", 2) != 2) {
@@ -683,9 +687,6 @@ int OSSL_HTTP_REQ_CTX_nbio(OSSL_HTTP_REQ_CTX *rctx)
         rctx->state = OHS_ERROR;
         return 0;
 
-    case OHS_ERROR:
-        return 0;
-
         /* State machine could be broken up at this point and bulky code sections factorized out. */
 
     case OHS_FIRSTLINE:
@@ -943,7 +944,6 @@ int OSSL_HTTP_REQ_CTX_nbio(OSSL_HTTP_REQ_CTX *rctx)
 
         /* Fall thru */
     case OHS_ASN1_CONTENT:
-    default:
         n = BIO_get_mem_data(rctx->mem, NULL);
         if (n < 0 || (size_t)n < rctx->resp_len)
             goto next_io;