curl/backport-CVE-2023-23916.patch
xinghe 9debe160e9 enable test
(cherry picked from commit a6541b26e510bc2d966c031d3808ed8a0e851c13)
2023-03-09 15:08:06 +08:00

55 lines
2.0 KiB
Diff

From 119fb187192a9ea13dc90d9d20c215fc82799ab9 Mon Sep 17 00:00:00 2001
From: Patrick Monnerat <patrick@monnerat.net>
Date: Mon, 13 Feb 2023 08:33:09 +0100
Subject: [PATCH] content_encoding: do not reset stage counter for each header
Test 418 verifies
Closes #10492
Conflict: remove tests/data/test387 tests/data/test418 tests/data/Makefile.inc
Reference: https://github.com/curl/curl/commit/119fb187192a9ea13dc
---
lib/content_encoding.c | 7 +-
lib/urldata.h | 1 +
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/lib/content_encoding.c b/lib/content_encoding.c
index 4a20142..3633791 100644
--- a/lib/content_encoding.c
+++ b/lib/content_encoding.c
@@ -945,7 +945,6 @@ CURLcode Curl_build_unencoding_stack(struct connectdata *conn,
{
struct Curl_easy *data = conn->data;
struct SingleRequest *k = &data->req;
- int counter = 0;
do {
const char *name;
@@ -980,9 +979,9 @@ CURLcode Curl_build_unencoding_stack(struct connectdata *conn,
if(!encoding)
encoding = &error_encoding; /* Defer error at stack use. */
- if(++counter >= MAX_ENCODE_STACK) {
- failf(data, "Reject response due to %u content encodings",
- counter);
+ if(k->writer_stack_depth++ >= MAX_ENCODE_STACK) {
+ failf(data, "Reject response due to more than %u content encodings",
+ MAX_ENCODE_STACK);
return CURLE_BAD_CONTENT_ENCODING;
}
/* Stack the unencoding stage. */
diff --git a/lib/urldata.h b/lib/urldata.h
index dc77061..27ee1b5 100644
--- a/lib/urldata.h
+++ b/lib/urldata.h
@@ -653,6 +653,7 @@ struct SingleRequest {
struct dohdata doh; /* DoH specific data for this request */
#endif
unsigned char setcookies;
+ unsigned char writer_stack_depth; /* Unencoding stack depth. */
BIT(header); /* incoming data has HTTP header */
BIT(content_range); /* set TRUE if Content-Range: was found */
BIT(upload_done); /* set to TRUE when doing chunked transfer-encoding
--
2.27.0