]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
http_client.c: make sure to raise error 404 (also in case of further errors like...
authorDr. David von Oheimb <dev@ddvo.net>
Tue, 14 Oct 2025 08:07:04 +0000 (10:07 +0200)
committerDr. David von Oheimb <dev@ddvo.net>
Wed, 15 Oct 2025 12:52:09 +0000 (14:52 +0200)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/28895)

crypto/http/http_client.c

index 15bd583d48b2d1d0cabd58060616f0a6750ea1e1..c5766aae155585008a3c6f258dc1613f3b4e85c5 100644 (file)
@@ -36,6 +36,7 @@
 #define HTTP_STATUS_CODE_MOVED_PERMANENTLY 301
 #define HTTP_STATUS_CODE_FOUND             302
 #define HTTP_STATUS_CODES_NONFATAL_ERROR   400
+#define HTTP_STATUS_CODE_NOT_FOUND         404
 
 /* Stateful HTTP request code, supporting blocking and non-blocking I/O */
 
@@ -488,11 +489,12 @@ static int parse_http_line1(char *line, int *found_keep_alive)
     case HTTP_STATUS_CODE_FOUND:
         return retcode;
     default:
-        if (retcode < HTTP_STATUS_CODES_NONFATAL_ERROR) {
+        if (retcode == HTTP_STATUS_CODE_NOT_FOUND
+            || retcode < HTTP_STATUS_CODES_NONFATAL_ERROR) {
             ERR_raise_data(ERR_LIB_HTTP, HTTP_R_STATUS_CODE_UNSUPPORTED, "code=%s", code);
             if (*reason != '\0')
                 ERR_add_error_data(2, ", reason=", reason);
-        } /* must return content normally if status >= 400 */
+        } /* must return content normally if status >= 400, still tentatively raised error on 404 */
         return retcode;
     }