Skip to content

Commit af488f8

Browse files
mcollinaBethGriggs
authored andcommittedOct 11, 2021
deps: update llhttp to 6.0.4
Refs: https://hackerone.com/reports/1238099 Refs: https://hackerone.com/reports/1238709 Refs: nodejs-private/llhttp-private#6 Refs: nodejs-private/llhttp-private#5 CVE-ID: CVE-2021-22959 CVE-ID: CVE-2021-22960 PR-URL: nodejs-private/node-private#284 Reviewed-By: Akshay K <iit.akshay@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com>
1 parent dfd5892 commit af488f8

File tree

5 files changed

+647
-402
lines changed

5 files changed

+647
-402
lines changed
 

‎deps/llhttp/CMakeLists.txt

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
cmake_minimum_required(VERSION 3.5.1)
2+
cmake_policy(SET CMP0069 NEW)
3+
4+
project(llhttp C)
5+
6+
set(CMAKE_C_STANDARD 99)
7+
8+
#
9+
# Options
10+
#
11+
# Generic option
12+
option(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" OFF)
13+
14+
# Source code
15+
set(LLHTTP_SOURCES
16+
src/llhttp.c
17+
src/http.c
18+
src/api.c
19+
)
20+
21+
set(LLHTTP_HEADERS
22+
include/llhttp.h
23+
)
24+
25+
add_library(llhttp)
26+
add_library(llhttp::llhttp ALIAS llhttp)
27+
28+
target_sources(llhttp PRIVATE ${LLHTTP_SOURCES} ${LLHTTP_HEADERS})
29+
30+
# On windows with Visual Studio, add a debug postfix so that release
31+
# and debug libraries can coexist.
32+
if(MSVC)
33+
set(CMAKE_DEBUG_POSTFIX "d")
34+
endif()
35+
36+
target_include_directories(llhttp PUBLIC
37+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
38+
$<INSTALL_INTERFACE:include>
39+
)
40+
41+
set_target_properties(llhttp PROPERTIES PUBLIC_HEADER ${LLHTTP_HEADERS})
42+
43+
install(TARGETS llhttp
44+
EXPORT llhttp
45+
ARCHIVE DESTINATION lib
46+
PUBLIC_HEADER DESTINATION include/
47+
)
48+
49+
# This is required to work with FetchContent
50+
install(EXPORT llhttp
51+
FILE llhttp-config.cmake
52+
NAMESPACE llhttp::
53+
DESTINATION lib/cmake/llhttp)

‎deps/llhttp/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,20 @@ For more information on API usage, please refer to [src/native/api.h](https://gi
9999
* Python: [pallas/pyllhttp][8]
100100
* Ruby: [metabahn/llhttp][9]
101101
102+
103+
### Using with CMake
104+
105+
If you want to use this library in a CMake project you can use the snippet below.
106+
107+
```
108+
FetchContent_Declare(llhttp
109+
URL "https://github.com/nodejs/llhttp/releases/download/v6.0.4/llhttp-release-v6.0.4.tar.gz") # Using version 6.0.4
110+
111+
FetchContent_MakeAvailable(llhttp)
112+
113+
target_link_libraries(${EXAMPLE_PROJECT_NAME} ${PROJECT_LIBRARIES} llhttp ${PROJECT_NAME})
114+
```
115+
102116
#### LICENSE
103117
104118
This software is licensed under the MIT License.

‎deps/llhttp/include/llhttp.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#define LLHTTP_VERSION_MAJOR 6
55
#define LLHTTP_VERSION_MINOR 0
6-
#define LLHTTP_VERSION_PATCH 2
6+
#define LLHTTP_VERSION_PATCH 4
77

88
#ifndef LLHTTP_STRICT_MODE
99
# define LLHTTP_STRICT_MODE 0

‎deps/llhttp/src/api.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,23 @@ extern int wasm_on_url(llhttp_t* p, const char* at, size_t length);
4646
extern int wasm_on_status(llhttp_t* p, const char* at, size_t length);
4747
extern int wasm_on_header_field(llhttp_t* p, const char* at, size_t length);
4848
extern int wasm_on_header_value(llhttp_t* p, const char* at, size_t length);
49-
extern int wasm_on_headers_complete(llhttp_t * p);
49+
extern int wasm_on_headers_complete(llhttp_t * p, int status_code,
50+
uint8_t upgrade, int should_keep_alive);
5051
extern int wasm_on_body(llhttp_t* p, const char* at, size_t length);
5152
extern int wasm_on_message_complete(llhttp_t * p);
5253

54+
static int wasm_on_headers_complete_wrap(llhttp_t* p) {
55+
return wasm_on_headers_complete(p, p->status_code, p->upgrade,
56+
llhttp_should_keep_alive(p));
57+
}
58+
5359
const llhttp_settings_t wasm_settings = {
5460
wasm_on_message_begin,
5561
wasm_on_url,
5662
wasm_on_status,
5763
wasm_on_header_field,
5864
wasm_on_header_value,
59-
wasm_on_headers_complete,
65+
wasm_on_headers_complete_wrap,
6066
wasm_on_body,
6167
wasm_on_message_complete,
6268
NULL,

‎deps/llhttp/src/llhttp.c

+571-399
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.