From 5aaf9746f649d15b3ad006acdc6a958819acc536 Mon Sep 17 00:00:00 2001 From: "Dr. David von Oheimb" Date: Tue, 14 Oct 2025 10:07:04 +0200 Subject: [PATCH] http_client.c: make sure to raise error 404 (also in case of further errors like content type mismatch) Reviewed-by: Tomas Mraz Reviewed-by: Dmitry Belyavskiy (Merged from https://github.com/openssl/openssl/pull/28895) --- crypto/http/http_client.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crypto/http/http_client.c b/crypto/http/http_client.c index 15bd583d48b..c5766aae155 100644 --- a/crypto/http/http_client.c +++ b/crypto/http/http_client.c @@ -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; } -- 2.47.3