[openssl] openssl-3.0 update

dev at ddvo.net dev at ddvo.net
Fri Dec 3 11:26:03 UTC 2021


The branch openssl-3.0 has been updated
       via  17f5c1d9bab0127260ec212c55fc7193fea099a5 (commit)
       via  1cafe4fc33c1dae7dd5024f600475fa96637b128 (commit)
      from  acf1651de1ba36e79176d9df0943698ed5bcee9c (commit)


- Log -----------------------------------------------------------------
commit 17f5c1d9bab0127260ec212c55fc7193fea099a5
Author: Dr. David von Oheimb <David.von.Oheimb at siemens.com>
Date:   Tue Nov 30 16:44:59 2021 +0100

    OSSL_HTTP_REQ_CTX_nbio(): Fix parsing of responses with status code != 200
    
    This way keep-alive is not (needlessly) cancelled on error.
    
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/17171)
    
    (cherry picked from commit 38288f424faa0cf61bd705c497bb1a1657611da1)

commit 1cafe4fc33c1dae7dd5024f600475fa96637b128
Author: Dr. David von Oheimb <David.von.Oheimb at siemens.com>
Date:   Tue Nov 30 16:20:26 2021 +0100

    parse_http_line1(): Fix diagnostic output on error and return code
    
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/17171)
    
    (cherry picked from commit e2b7dc353b353efccd1d228f743baa7c2d2f9f49)

-----------------------------------------------------------------------

Summary of changes:
 crypto/http/http_client.c | 39 +++++++++++++++++++++------------------
 1 file changed, 21 insertions(+), 18 deletions(-)

diff --git a/crypto/http/http_client.c b/crypto/http/http_client.c
index e5c8bcd33d..6a8149ba59 100644
--- a/crypto/http/http_client.c
+++ b/crypto/http/http_client.c
@@ -369,12 +369,13 @@ static OSSL_HTTP_REQ_CTX *http_req_ctx_new(int free_wbio, BIO *wbio, BIO *rbio,
 
 /*
  * Parse first HTTP response line. This should be like this: "HTTP/1.0 200 OK".
- * We need to obtain the numeric code and (optional) informational message.
+ * We need to obtain the status code and (optional) informational message.
+ * Return any received HTTP response status code, or 0 on fatal error.
  */
 
 static int parse_http_line1(char *line, int *found_keep_alive)
 {
-    int i, retcode;
+    int i, retcode, err;
     char *code, *reason, *end;
 
     if (!HAS_PREFIX(line, HTTP_PREFIX_VERSION))
@@ -430,22 +431,21 @@ static int parse_http_line1(char *line, int *found_keep_alive)
     case HTTP_STATUS_CODE_FOUND:
         return retcode;
     default:
+        err = HTTP_R_RECEIVED_ERROR;
         if (retcode < 400)
-            retcode = HTTP_R_STATUS_CODE_UNSUPPORTED;
-        else
-            retcode = HTTP_R_RECEIVED_ERROR;
+            err = HTTP_R_STATUS_CODE_UNSUPPORTED;
         if (*reason == '\0')
-            ERR_raise_data(ERR_LIB_HTTP, retcode, "code=%s", code);
+            ERR_raise_data(ERR_LIB_HTTP, err, "code=%s", code);
         else
-            ERR_raise_data(ERR_LIB_HTTP, retcode,
-                           "code=%s, reason=%s", code, reason);
-        return 0;
+            ERR_raise_data(ERR_LIB_HTTP, err, "code=%s, reason=%s", code,
+                           reason);
+        return retcode;
     }
 
  err:
-    i = 0;
-    while (i < 60 && ossl_isprint(line[i]))
-        i++;
+    for (i = 0; i < 60 && line[i] != '\0'; i++)
+        if (!ossl_isprint(line[i]))
+            line[i] = ' ';
     line[i] = '\0';
     ERR_raise_data(ERR_LIB_HTTP, HTTP_R_HEADER_PARSE_ERROR, "content=%s", line);
     return 0;
@@ -634,7 +634,7 @@ int OSSL_HTTP_REQ_CTX_nbio(OSSL_HTTP_REQ_CTX *rctx)
                 /* fall through */
             default:
                 rctx->state = OHS_ERROR;
-                return 0;
+                goto next_line;
             }
         }
         key = buf;
@@ -693,11 +693,6 @@ int OSSL_HTTP_REQ_CTX_nbio(OSSL_HTTP_REQ_CTX *rctx)
         if (*p != '\0') /* not end of headers */
             goto next_line;
 
-        if (rctx->expected_ct != NULL && !found_expected_ct) {
-            ERR_raise_data(ERR_LIB_HTTP, HTTP_R_MISSING_CONTENT_TYPE,
-                           "expected=%s", rctx->expected_ct);
-            return 0;
-        }
         if (rctx->keep_alive != 0 /* do not let server initiate keep_alive */
                 && !found_keep_alive /* otherwise there is no change */) {
             if (rctx->keep_alive == 2) {
@@ -708,6 +703,14 @@ int OSSL_HTTP_REQ_CTX_nbio(OSSL_HTTP_REQ_CTX *rctx)
             rctx->keep_alive = 0;
         }
 
+        if (rctx->state == OHS_ERROR)
+            return 0;
+
+        if (rctx->expected_ct != NULL && !found_expected_ct) {
+            ERR_raise_data(ERR_LIB_HTTP, HTTP_R_MISSING_CONTENT_TYPE,
+                           "expected=%s", rctx->expected_ct);
+            return 0;
+        }
         if (rctx->state == OHS_REDIRECT) {
             /* http status code indicated redirect but there was no Location */
             ERR_raise(ERR_LIB_HTTP, HTTP_R_MISSING_REDIRECT_LOCATION);


More information about the openssl-commits mailing list