Skip to content

Commit

Permalink
deps: update llhttp to 6.0.4
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mcollina authored and BethGriggs committed Oct 11, 2021
1 parent dfd5892 commit af488f8
Show file tree
Hide file tree
Showing 5 changed files with 647 additions and 402 deletions.
53 changes: 53 additions & 0 deletions deps/llhttp/CMakeLists.txt
@@ -0,0 +1,53 @@
cmake_minimum_required(VERSION 3.5.1)
cmake_policy(SET CMP0069 NEW)

project(llhttp C)

set(CMAKE_C_STANDARD 99)

#
# Options
#
# Generic option
option(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" OFF)

# Source code
set(LLHTTP_SOURCES
src/llhttp.c
src/http.c
src/api.c
)

set(LLHTTP_HEADERS
include/llhttp.h
)

add_library(llhttp)
add_library(llhttp::llhttp ALIAS llhttp)

target_sources(llhttp PRIVATE ${LLHTTP_SOURCES} ${LLHTTP_HEADERS})

# On windows with Visual Studio, add a debug postfix so that release
# and debug libraries can coexist.
if(MSVC)
set(CMAKE_DEBUG_POSTFIX "d")
endif()

target_include_directories(llhttp PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)

set_target_properties(llhttp PROPERTIES PUBLIC_HEADER ${LLHTTP_HEADERS})

install(TARGETS llhttp
EXPORT llhttp
ARCHIVE DESTINATION lib
PUBLIC_HEADER DESTINATION include/
)

# This is required to work with FetchContent
install(EXPORT llhttp
FILE llhttp-config.cmake
NAMESPACE llhttp::
DESTINATION lib/cmake/llhttp)
14 changes: 14 additions & 0 deletions deps/llhttp/README.md
Expand Up @@ -99,6 +99,20 @@ For more information on API usage, please refer to [src/native/api.h](https://gi
* Python: [pallas/pyllhttp][8]
* Ruby: [metabahn/llhttp][9]
### Using with CMake
If you want to use this library in a CMake project you can use the snippet below.
```
FetchContent_Declare(llhttp
URL "https://github.com/nodejs/llhttp/releases/download/v6.0.4/llhttp-release-v6.0.4.tar.gz") # Using version 6.0.4

FetchContent_MakeAvailable(llhttp)

target_link_libraries(${EXAMPLE_PROJECT_NAME} ${PROJECT_LIBRARIES} llhttp ${PROJECT_NAME})
```
#### LICENSE
This software is licensed under the MIT License.
Expand Down
2 changes: 1 addition & 1 deletion deps/llhttp/include/llhttp.h
Expand Up @@ -3,7 +3,7 @@

#define LLHTTP_VERSION_MAJOR 6
#define LLHTTP_VERSION_MINOR 0
#define LLHTTP_VERSION_PATCH 2
#define LLHTTP_VERSION_PATCH 4

#ifndef LLHTTP_STRICT_MODE
# define LLHTTP_STRICT_MODE 0
Expand Down
10 changes: 8 additions & 2 deletions deps/llhttp/src/api.c
Expand Up @@ -46,17 +46,23 @@ extern int wasm_on_url(llhttp_t* p, const char* at, size_t length);
extern int wasm_on_status(llhttp_t* p, const char* at, size_t length);
extern int wasm_on_header_field(llhttp_t* p, const char* at, size_t length);
extern int wasm_on_header_value(llhttp_t* p, const char* at, size_t length);
extern int wasm_on_headers_complete(llhttp_t * p);
extern int wasm_on_headers_complete(llhttp_t * p, int status_code,
uint8_t upgrade, int should_keep_alive);
extern int wasm_on_body(llhttp_t* p, const char* at, size_t length);
extern int wasm_on_message_complete(llhttp_t * p);

static int wasm_on_headers_complete_wrap(llhttp_t* p) {
return wasm_on_headers_complete(p, p->status_code, p->upgrade,
llhttp_should_keep_alive(p));
}

const llhttp_settings_t wasm_settings = {
wasm_on_message_begin,
wasm_on_url,
wasm_on_status,
wasm_on_header_field,
wasm_on_header_value,
wasm_on_headers_complete,
wasm_on_headers_complete_wrap,
wasm_on_body,
wasm_on_message_complete,
NULL,
Expand Down

0 comments on commit af488f8

Please sign in to comment.