-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: stricter Transfer-Encoding and header separator parsing
Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> PR-URL: nodejs-private/node-private#315 CVE-ID: CVE-2022-32215,CVE-2022-32214,CVE-2022-32212 Backport-PR-URL: nodejs-private/node-private#326
- Loading branch information
1 parent
c087644
commit 1da22eb
Showing
11 changed files
with
1,037 additions
and
460 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,115 @@ | ||
cmake_minimum_required(VERSION 3.5.1) | ||
cmake_policy(SET CMP0069 NEW) | ||
|
||
project(llhttp C) | ||
project(llhttp VERSION 6.0.5) | ||
include(GNUInstallDirs) | ||
|
||
set(CMAKE_C_STANDARD 99) | ||
|
||
# By default build in relwithdebinfo type, supports both lowercase and uppercase | ||
if(NOT CMAKE_CONFIGURATION_TYPES) | ||
set(allowableBuileTypes DEBUG RELEASE RELWITHDEBINFO MINSIZEREL) | ||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "${allowableBuileTypes}") | ||
if(NOT CMAKE_BUILD_TYPE) | ||
set(CMAKE_BUILD_TYPE RELWITHDEBINFO CACHE STRING "" FORCE) | ||
else() | ||
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE) | ||
if(NOT CMAKE_BUILD_TYPE IN_LIST allowableBuileTypes) | ||
message(FATEL_ERROR "Invalid build type: ${CMAKE_BUILD_TYPE}") | ||
endif() | ||
endif() | ||
endif() | ||
|
||
# | ||
# Options | ||
# | ||
# Generic option | ||
option(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" OFF) | ||
option(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so)" ON) | ||
option(BUILD_STATIC_LIBS "Build static libraries (.lib/.a)" OFF) | ||
|
||
# Source code | ||
set(LLHTTP_SOURCES | ||
src/llhttp.c | ||
src/http.c | ||
src/api.c | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/llhttp.c | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/http.c | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/api.c | ||
) | ||
|
||
set(LLHTTP_HEADERS | ||
include/llhttp.h | ||
${CMAKE_CURRENT_SOURCE_DIR}/include/llhttp.h | ||
) | ||
|
||
add_library(llhttp) | ||
add_library(llhttp::llhttp ALIAS llhttp) | ||
configure_file( | ||
${CMAKE_CURRENT_SOURCE_DIR}/libllhttp.pc.in | ||
${CMAKE_CURRENT_SOURCE_DIR}/libllhttp.pc | ||
@ONLY | ||
) | ||
|
||
target_sources(llhttp PRIVATE ${LLHTTP_SOURCES} ${LLHTTP_HEADERS}) | ||
function(config_library target) | ||
target_sources(${target} 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(${target} PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR}/include | ||
) | ||
|
||
target_include_directories(llhttp PUBLIC | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:include> | ||
) | ||
set_target_properties(${target} PROPERTIES | ||
OUTPUT_NAME llhttp | ||
VERSION ${PROJECT_VERSION} | ||
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} | ||
PUBLIC_HEADER ${LLHTTP_HEADERS} | ||
) | ||
|
||
set_target_properties(llhttp PROPERTIES PUBLIC_HEADER ${LLHTTP_HEADERS}) | ||
install(TARGETS ${target} | ||
EXPORT llhttp | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} | ||
) | ||
|
||
install(TARGETS llhttp | ||
EXPORT llhttp | ||
ARCHIVE DESTINATION lib | ||
PUBLIC_HEADER DESTINATION include/ | ||
) | ||
install(FILES | ||
${CMAKE_CURRENT_SOURCE_DIR}/libllhttp.pc | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig | ||
) | ||
|
||
# This is required to work with FetchContent | ||
install(EXPORT llhttp | ||
# This is required to work with FetchContent | ||
install(EXPORT llhttp | ||
FILE llhttp-config.cmake | ||
NAMESPACE llhttp:: | ||
DESTINATION lib/cmake/llhttp) | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/llhttp) | ||
endfunction(config_library target) | ||
|
||
if(BUILD_SHARED_LIBS) | ||
add_library(llhttp_shared SHARED | ||
${llhttp_src} | ||
) | ||
add_library(llhttp::llhttp ALIAS llhttp_shared) | ||
config_library(llhttp_shared) | ||
endif() | ||
|
||
if(BUILD_STATIC_LIBS) | ||
add_library(llhttp_static STATIC | ||
${llhttp_src} | ||
) | ||
if(BUILD_SHARED_LIBS) | ||
add_library(llhttp::llhttp ALIAS llhttp_shared) | ||
else() | ||
add_library(llhttp::llhttp ALIAS llhttp_static) | ||
endif() | ||
config_library(llhttp_static) | ||
endif() | ||
|
||
# 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() | ||
|
||
# Print project configure summary | ||
message(STATUS "") | ||
message(STATUS "") | ||
message(STATUS "Project configure summary:") | ||
message(STATUS "") | ||
message(STATUS " CMake build type .................: ${CMAKE_BUILD_TYPE}") | ||
message(STATUS " Install prefix ...................: ${CMAKE_INSTALL_PREFIX}") | ||
message(STATUS " Build shared library .............: ${BUILD_SHARED_LIBS}") | ||
message(STATUS " Build static library .............: ${BUILD_STATIC_LIBS}") | ||
message(STATUS "") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
prefix=@CMAKE_INSTALL_PREFIX@ | ||
exec_prefix=@CMAKE_INSTALL_PREFIX@ | ||
libdir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@ | ||
includedir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@ | ||
|
||
Name: libllhttp | ||
Description: Node.js llhttp Library | ||
Version: @PROJECT_VERSION@ | ||
Libs: -L${libdir} -lllhttp | ||
Cflags: -I${includedir} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.