Skip to content

Commit 190e45a

Browse files
ShogunPandaRafaelGSS
authored andcommitted
deps: update llhttp to 9.1.2
PR-URL: #48981 Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Marco Ippolito <[email protected]> CVE-ID: CVE-2025-23167
1 parent 5357d0b commit 190e45a

18 files changed

+1779
-10093
lines changed

deps/llhttp/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
libllhttp.pc

deps/llhttp/CMakeLists.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.5.1)
22
cmake_policy(SET CMP0069 NEW)
33

4-
project(llhttp VERSION 8.1.2)
4+
project(llhttp VERSION 9.1.2)
55
include(GNUInstallDirs)
66

77
set(CMAKE_C_STANDARD 99)
@@ -47,8 +47,9 @@ configure_file(
4747
function(config_library target)
4848
target_sources(${target} PRIVATE ${LLHTTP_SOURCES} ${LLHTTP_HEADERS})
4949

50-
target_include_directories(${target} PRIVATE
51-
${CMAKE_CURRENT_SOURCE_DIR}/include
50+
target_include_directories(${target} PUBLIC
51+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
52+
$<INSTALL_INTERFACE:include>
5253
)
5354

5455
set_target_properties(${target} PROPERTIES
@@ -72,9 +73,10 @@ function(config_library target)
7273

7374
# This is required to work with FetchContent
7475
install(EXPORT llhttp
75-
FILE llhttp-config.cmake
76-
NAMESPACE llhttp::
77-
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/llhttp)
76+
FILE llhttp-config.cmake
77+
NAMESPACE llhttp::
78+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/llhttp
79+
)
7880
endfunction(config_library target)
7981

8082
if(BUILD_SHARED_LIBS)

deps/llhttp/README.md

Lines changed: 94 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -61,33 +61,41 @@ checks could be performed to get even stricter verification of the llhttp.
6161
## Usage
6262

6363
```C
64+
#include "stdio.h"
6465
#include "llhttp.h"
66+
#include "string.h"
6567

66-
llhttp_t parser;
67-
llhttp_settings_t settings;
68+
int handle_on_message_complete(llhttp_t* parser) {
69+
fprintf(stdout, "Message completed!\n");
70+
return 0;
71+
}
72+
73+
int main() {
74+
llhttp_t parser;
75+
llhttp_settings_t settings;
6876

69-
/* Initialize user callbacks and settings */
70-
llhttp_settings_init(&settings);
77+
/*Initialize user callbacks and settings */
78+
llhttp_settings_init(&settings);
7179

72-
/* Set user callback */
73-
settings.on_message_complete = handle_on_message_complete;
80+
/*Set user callback */
81+
settings.on_message_complete = handle_on_message_complete;
7482

75-
/* Initialize the parser in HTTP_BOTH mode, meaning that it will select between
76-
* HTTP_REQUEST and HTTP_RESPONSE parsing automatically while reading the first
77-
* input.
78-
*/
79-
llhttp_init(&parser, HTTP_BOTH, &settings);
83+
/*Initialize the parser in HTTP_BOTH mode, meaning that it will select between
84+
*HTTP_REQUEST and HTTP_RESPONSE parsing automatically while reading the first
85+
*input.
86+
*/
87+
llhttp_init(&parser, HTTP_BOTH, &settings);
8088

81-
/* Parse request! */
82-
const char* request = "GET / HTTP/1.1\r\n\r\n";
83-
int request_len = strlen(request);
89+
/*Parse request! */
90+
const char* request = "GET / HTTP/1.1\r\n\r\n";
91+
int request_len = strlen(request);
8492

85-
enum llhttp_errno err = llhttp_execute(&parser, request, request_len);
86-
if (err == HPE_OK) {
87-
/* Successfully parsed! */
88-
} else {
89-
fprintf(stderr, "Parse error: %s %s\n", llhttp_errno_name(err),
90-
parser.reason);
93+
enum llhttp_errno err = llhttp_execute(&parser, request, request_len);
94+
if (err == HPE_OK) {
95+
fprintf(stdout, "Successfully parsed!\n");
96+
} else {
97+
fprintf(stderr, "Parse error: %s %s\n", llhttp_errno_name(err), parser.reason);
98+
}
9199
}
92100
```
93101
For more information on API usage, please refer to [src/native/api.h](https://github.com/nodejs/llhttp/blob/main/src/native/api.h).
@@ -279,7 +287,7 @@ protocol support to highly non-compliant clients/server.
279287
No `HPE_INVALID_HEADER_TOKEN` will be raised for incorrect header values when
280288
lenient parsing is "on".
281289
282-
**USE AT YOUR OWN RISK!**
290+
**Enabling this flag can pose a security issue since you will be exposed to request smuggling attacks. USE WITH CAUTION!**
283291
284292
### `void llhttp_set_lenient_chunked_length(llhttp_t* parser, int enabled)`
285293
@@ -292,23 +300,22 @@ conjunction with `Content-Length`.
292300
This error is important to prevent HTTP request smuggling, but may be less desirable
293301
for small number of cases involving legacy servers.
294302
295-
**USE AT YOUR OWN RISK!**
303+
**Enabling this flag can pose a security issue since you will be exposed to request smuggling attacks. USE WITH CAUTION!**
296304
297305
### `void llhttp_set_lenient_keep_alive(llhttp_t* parser, int enabled)`
298306
299307
Enables/disables lenient handling of `Connection: close` and HTTP/1.0
300308
requests responses.
301309
302-
Normally `llhttp` would error on (in strict mode) or discard (in loose mode)
303-
the HTTP request/response after the request/response with `Connection: close`
304-
and `Content-Length`.
310+
Normally `llhttp` would error the HTTP request/response
311+
after the request/response with `Connection: close` and `Content-Length`.
305312
306313
This is important to prevent cache poisoning attacks,
307314
but might interact badly with outdated and insecure clients.
308315
309316
With this flag the extra request/response will be parsed normally.
310317
311-
**USE AT YOUR OWN RISK!**
318+
**Enabling this flag can pose a security issue since you will be exposed to poisoning attacks. USE WITH CAUTION!**
312319
313320
### `void llhttp_set_lenient_transfer_encoding(llhttp_t* parser, int enabled)`
314321
@@ -323,7 +330,67 @@ avoid request smuggling.
323330
324331
With this flag the extra value will be parsed normally.
325332
326-
**USE AT YOUR OWN RISK!**
333+
**Enabling this flag can pose a security issue since you will be exposed to request smuggling attacks. USE WITH CAUTION!**
334+
335+
### `void llhttp_set_lenient_version(llhttp_t* parser, int enabled)`
336+
337+
Enables/disables lenient handling of HTTP version.
338+
339+
Normally `llhttp` would error when the HTTP version in the request or status line
340+
is not `0.9`, `1.0`, `1.1` or `2.0`.
341+
With this flag the extra value will be parsed normally.
342+
343+
**Enabling this flag can pose a security issue since you will allow unsupported HTTP versions. USE WITH CAUTION!**
344+
345+
### `void llhttp_set_lenient_data_after_close(llhttp_t* parser, int enabled)`
346+
347+
Enables/disables lenient handling of additional data received after a message ends
348+
and keep-alive is disabled.
349+
350+
Normally `llhttp` would error when additional unexpected data is received if the message
351+
contains the `Connection` header with `close` value.
352+
With this flag the extra data will discarded without throwing an error.
353+
354+
**Enabling this flag can pose a security issue since you will be exposed to poisoning attacks. USE WITH CAUTION!**
355+
356+
### `void llhttp_set_lenient_optional_lf_after_cr(llhttp_t* parser, int enabled)`
357+
358+
Enables/disables lenient handling of incomplete CRLF sequences.
359+
360+
Normally `llhttp` would error when a CR is not followed by LF when terminating the
361+
request line, the status line, the headers or a chunk header.
362+
With this flag only a CR is required to terminate such sections.
363+
364+
**Enabling this flag can pose a security issue since you will be exposed to request smuggling attacks. USE WITH CAUTION!**
365+
366+
### `void llhttp_set_lenient_optional_cr_before_lf(llhttp_t* parser, int enabled)`
367+
368+
Enables/disables lenient handling of line separators.
369+
370+
Normally `llhttp` would error when a LF is not preceded by CR when terminating the
371+
request line, the status line, the headers, a chunk header or a chunk data.
372+
With this flag only a LF is required to terminate such sections.
373+
374+
**Enabling this flag can pose a security issue since you will be exposed to request smuggling attacks. USE WITH CAUTION!**
375+
376+
### `void llhttp_set_lenient_optional_crlf_after_chunk(llhttp_t* parser, int enabled)`
377+
378+
Enables/disables lenient handling of chunks not separated via CRLF.
379+
380+
Normally `llhttp` would error when after a chunk data a CRLF is missing before
381+
starting a new chunk.
382+
With this flag the new chunk can start immediately after the previous one.
383+
384+
**Enabling this flag can pose a security issue since you will be exposed to request smuggling attacks. USE WITH CAUTION!**
385+
386+
### `void llhttp_set_lenient_spaces_after_chunk_size(llhttp_t* parser, int enabled)`
387+
388+
Enables/disables lenient handling of spaces after chunk size.
389+
390+
Normally `llhttp` would error when after a chunk size is followed by one or more spaces are present instead of a CRLF or `;`.
391+
With this flag this check is disabled.
392+
393+
**Enabling this flag can pose a security issue since you will be exposed to request smuggling attacks. USE WITH CAUTION!**
327394
328395
## Build Instructions
329396

deps/llhttp/include/llhttp.h

Lines changed: 94 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1+
12
#ifndef INCLUDE_LLHTTP_H_
23
#define INCLUDE_LLHTTP_H_
34

4-
#define LLHTTP_VERSION_MAJOR 8
5+
#define LLHTTP_VERSION_MAJOR 9
56
#define LLHTTP_VERSION_MINOR 1
67
#define LLHTTP_VERSION_PATCH 2
78

8-
#ifndef LLHTTP_STRICT_MODE
9-
# define LLHTTP_STRICT_MODE 0
10-
#endif
11-
129
#ifndef INCLUDE_LLHTTP_ITSELF_H_
1310
#define INCLUDE_LLHTTP_ITSELF_H_
1411
#ifdef __cplusplus
@@ -33,7 +30,7 @@ struct llhttp__internal_s {
3330
uint8_t http_major;
3431
uint8_t http_minor;
3532
uint8_t header_state;
36-
uint8_t lenient_flags;
33+
uint16_t lenient_flags;
3734
uint8_t upgrade;
3835
uint8_t finish;
3936
uint16_t flags;
@@ -50,6 +47,7 @@ int llhttp__internal_execute(llhttp__internal_t* s, const char* p, const char* e
5047
#endif
5148
#endif /* INCLUDE_LLHTTP_ITSELF_H_ */
5249

50+
5351
#ifndef LLLLHTTP_C_HEADERS_
5452
#define LLLLHTTP_C_HEADERS_
5553
#ifdef __cplusplus
@@ -114,7 +112,12 @@ enum llhttp_lenient_flags {
114112
LENIENT_CHUNKED_LENGTH = 0x2,
115113
LENIENT_KEEP_ALIVE = 0x4,
116114
LENIENT_TRANSFER_ENCODING = 0x8,
117-
LENIENT_VERSION = 0x10
115+
LENIENT_VERSION = 0x10,
116+
LENIENT_DATA_AFTER_CLOSE = 0x20,
117+
LENIENT_OPTIONAL_LF_AFTER_CR = 0x40,
118+
LENIENT_OPTIONAL_CRLF_AFTER_CHUNK = 0x80,
119+
LENIENT_OPTIONAL_CR_BEFORE_LF = 0x100,
120+
LENIENT_SPACES_AFTER_CHUNK_SIZE = 0x200
118121
};
119122
typedef enum llhttp_lenient_flags llhttp_lenient_flags_t;
120123

@@ -534,6 +537,7 @@ typedef enum llhttp_status llhttp_status_t;
534537
#endif
535538
#endif /* LLLLHTTP_C_HEADERS_ */
536539

540+
537541
#ifndef INCLUDE_LLHTTP_API_H_
538542
#define INCLUDE_LLHTTP_API_H_
539543
#ifdef __cplusplus
@@ -759,7 +763,8 @@ const char* llhttp_status_name(llhttp_status_t status);
759763
* `HPE_INVALID_HEADER_TOKEN` will be raised for incorrect header values when
760764
* lenient parsing is "on".
761765
*
762-
* **(USE AT YOUR OWN RISK)**
766+
* **Enabling this flag can pose a security issue since you will be exposed to
767+
* request smuggling attacks. USE WITH CAUTION!**
763768
*/
764769
LLHTTP_EXPORT
765770
void llhttp_set_lenient_headers(llhttp_t* parser, int enabled);
@@ -773,7 +778,8 @@ void llhttp_set_lenient_headers(llhttp_t* parser, int enabled);
773778
* request smuggling, but may be less desirable for small number of cases
774779
* involving legacy servers.
775780
*
776-
* **(USE AT YOUR OWN RISK)**
781+
* **Enabling this flag can pose a security issue since you will be exposed to
782+
* request smuggling attacks. USE WITH CAUTION!**
777783
*/
778784
LLHTTP_EXPORT
779785
void llhttp_set_lenient_chunked_length(llhttp_t* parser, int enabled);
@@ -788,7 +794,8 @@ void llhttp_set_lenient_chunked_length(llhttp_t* parser, int enabled);
788794
* but might interact badly with outdated and insecure clients. With this flag
789795
* the extra request/response will be parsed normally.
790796
*
791-
* **(USE AT YOUR OWN RISK)**
797+
* **Enabling this flag can pose a security issue since you will be exposed to
798+
* poisoning attacks. USE WITH CAUTION!**
792799
*/
793800
LLHTTP_EXPORT
794801
void llhttp_set_lenient_keep_alive(llhttp_t* parser, int enabled);
@@ -802,14 +809,90 @@ void llhttp_set_lenient_keep_alive(llhttp_t* parser, int enabled);
802809
* avoid request smuggling.
803810
* With this flag the extra value will be parsed normally.
804811
*
805-
* **(USE AT YOUR OWN RISK)**
812+
* **Enabling this flag can pose a security issue since you will be exposed to
813+
* request smuggling attacks. USE WITH CAUTION!**
806814
*/
807815
LLHTTP_EXPORT
808816
void llhttp_set_lenient_transfer_encoding(llhttp_t* parser, int enabled);
809817

818+
/* Enables/disables lenient handling of HTTP version.
819+
*
820+
* Normally `llhttp` would error when the HTTP version in the request or status line
821+
* is not `0.9`, `1.0`, `1.1` or `2.0`.
822+
* With this flag the invalid value will be parsed normally.
823+
*
824+
* **Enabling this flag can pose a security issue since you will allow unsupported
825+
* HTTP versions. USE WITH CAUTION!**
826+
*/
827+
LLHTTP_EXPORT
828+
void llhttp_set_lenient_version(llhttp_t* parser, int enabled);
829+
830+
/* Enables/disables lenient handling of additional data received after a message ends
831+
* and keep-alive is disabled.
832+
*
833+
* Normally `llhttp` would error when additional unexpected data is received if the message
834+
* contains the `Connection` header with `close` value.
835+
* With this flag the extra data will discarded without throwing an error.
836+
*
837+
* **Enabling this flag can pose a security issue since you will be exposed to
838+
* poisoning attacks. USE WITH CAUTION!**
839+
*/
840+
LLHTTP_EXPORT
841+
void llhttp_set_lenient_data_after_close(llhttp_t* parser, int enabled);
842+
843+
/* Enables/disables lenient handling of incomplete CRLF sequences.
844+
*
845+
* Normally `llhttp` would error when a CR is not followed by LF when terminating the
846+
* request line, the status line, the headers or a chunk header.
847+
* With this flag only a CR is required to terminate such sections.
848+
*
849+
* **Enabling this flag can pose a security issue since you will be exposed to
850+
* request smuggling attacks. USE WITH CAUTION!**
851+
*/
852+
LLHTTP_EXPORT
853+
void llhttp_set_lenient_optional_lf_after_cr(llhttp_t* parser, int enabled);
854+
855+
/*
856+
* Enables/disables lenient handling of line separators.
857+
*
858+
* Normally `llhttp` would error when a LF is not preceded by CR when terminating the
859+
* request line, the status line, the headers, a chunk header or a chunk data.
860+
* With this flag only a LF is required to terminate such sections.
861+
*
862+
* **Enabling this flag can pose a security issue since you will be exposed to
863+
* request smuggling attacks. USE WITH CAUTION!**
864+
*/
865+
LLHTTP_EXPORT
866+
void llhttp_set_lenient_optional_cr_before_lf(llhttp_t* parser, int enabled);
867+
868+
/* Enables/disables lenient handling of chunks not separated via CRLF.
869+
*
870+
* Normally `llhttp` would error when after a chunk data a CRLF is missing before
871+
* starting a new chunk.
872+
* With this flag the new chunk can start immediately after the previous one.
873+
*
874+
* **Enabling this flag can pose a security issue since you will be exposed to
875+
* request smuggling attacks. USE WITH CAUTION!**
876+
*/
877+
LLHTTP_EXPORT
878+
void llhttp_set_lenient_optional_crlf_after_chunk(llhttp_t* parser, int enabled);
879+
880+
/* Enables/disables lenient handling of spaces after chunk size.
881+
*
882+
* Normally `llhttp` would error when after a chunk size is followed by one or more
883+
* spaces are present instead of a CRLF or `;`.
884+
* With this flag this check is disabled.
885+
*
886+
* **Enabling this flag can pose a security issue since you will be exposed to
887+
* request smuggling attacks. USE WITH CAUTION!**
888+
*/
889+
LLHTTP_EXPORT
890+
void llhttp_set_lenient_spaces_after_chunk_size(llhttp_t* parser, int enabled);
891+
810892
#ifdef __cplusplus
811893
} /* extern "C" */
812894
#endif
813895
#endif /* INCLUDE_LLHTTP_API_H_ */
814896

897+
815898
#endif /* INCLUDE_LLHTTP_H_ */

0 commit comments

Comments
 (0)