Skip to content

Commit

Permalink
Merge branch 'dev' into patch-OSV-2024-382
Browse files Browse the repository at this point in the history
  • Loading branch information
tigercosmos authored Jan 31, 2025
2 parents 0ebbb23 + 3af7383 commit 3c97bbb
Show file tree
Hide file tree
Showing 138 changed files with 5,089 additions and 4,958 deletions.
34 changes: 34 additions & 0 deletions .clang-tidy-new
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Checks: 'cert-*,
clang-analyzer-*,
concurrency-*,
cppcoreguidelines-*,
misc-*,
modernize-*,
performance-*,
portability-*,
readability-*,
-cert-env33-c,
-cert-err58-cpp,
-clang-analyzer-optin.cplusplus.VirtualCall,
-cppcoreguidelines-avoid-c-arrays,
-cppcoreguidelines-avoid-do-while,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-avoid-non-const-global-variables,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-owning-memory,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-cppcoreguidelines-pro-bounds-constant-array-index,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-cppcoreguidelines-pro-type-reinterpret-cast,
-cppcoreguidelines-pro-type-const-cast,
-cppcoreguidelines-pro-type-vararg,
-cppcoreguidelines-special-member-functions,
-modernize-avoid-c-arrays,
-modernize-use-trailing-return-type,
-misc-header-include-cycle,
-misc-include-cleaner,
-misc-no-recursion,
-misc-non-private-member-variables-in-classes,
-misc-use-anonymous-namespace,
-readability-function-cognitive-complexity,
-readability-magic-numbers'
2 changes: 1 addition & 1 deletion .codespellrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[codespell]
skip = *.dat,typos-config.toml,.git,.venv,./ci,./Dist,./mk,./Tests/ExamplesTest/expected_output,./Tests/ExamplesTest/pcap_examples,./Tests/Packet++Test/PacketExamples,./Tests/Pcap++Test/PcapExamples,./3rdParty,./Examples/PcapSearch/dirent-for-Visual-Studio
skip = *.dat,typos-config.toml,.git,.venv,venv,./out,./ci,./Dist,./mk,./Tests/ExamplesTest/expected_output,./Tests/ExamplesTest/pcap_examples,./Tests/Packet++Test/PacketExamples,./Tests/Pcap++Test/PcapExamples,./3rdParty,./Examples/PcapSearch/dirent-for-Visual-Studio
ignore-words = codespell-ignore-list.txt
count =
4 changes: 2 additions & 2 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
apk update && apk add cppcheck python3-dev
python3 -m venv .venv
. .venv/bin/activate
python3 -m pip install pre-commit setuptools clang-format==18.1.6 clang-tidy==18.1.8
python3 -m pip install pre-commit setuptools clang-format==19.1.6 clang-tidy==18.1.8
- name: Run pre-commit
run: |
Expand Down Expand Up @@ -701,7 +701,7 @@ jobs:
./gradlew assembleDebug
xdp:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

steps:
- name: Checkout code
Expand Down
7 changes: 4 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
exclude: '.*\.(pcap|pcapng|dat|txt)'
exclude: '.*\.(pcap|pcapng|dat)|(PacketExamples|PcapExamples|expected_output|pcap_examples).*\.txt'
fail_fast: false
repos:
- repo: local
Expand All @@ -22,7 +22,7 @@ repos:
args: ['--fix=lf']
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.1
rev: v0.8.4
hooks:
- id: ruff # Run the linter.
types_or: [ python ]
Expand All @@ -41,13 +41,14 @@ repos:
rev: 0.17.1
hooks:
- id: gersemi
args: ["-c"]
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
pass_filenames: false
- repo: https://github.com/crate-ci/typos
rev: v1.28.1
rev: codespell-dict-v0.5.0
hooks:
- id: typos
args: ['--config=typos-config.toml']
Expand Down
3 changes: 2 additions & 1 deletion 3rdParty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ if(PCAPPP_INSTALL)
EXPORT PcapPlusPlusTargets
ARCHIVE DESTINATION ${PCAPPP_INSTALL_LIBDIR}
LIBRARY DESTINATION ${PCAPPP_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${PCAPPP_INSTALL_INCLUDEDIR})
PUBLIC_HEADER DESTINATION ${PCAPPP_INSTALL_INCLUDEDIR}
)
endif()
6 changes: 2 additions & 4 deletions 3rdParty/EndianPortable/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
add_library(EndianPortable INTERFACE)

target_include_directories(EndianPortable
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_include_directories(EndianPortable INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)

target_sources(EndianPortable
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include/EndianPortable.h)
target_sources(EndianPortable INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include/EndianPortable.h)
6 changes: 2 additions & 4 deletions 3rdParty/Getopt-for-Visual-Studio/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
add_library(Getopt-for-Visual-Studio INTERFACE)

target_include_directories(Getopt-for-Visual-Studio
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/)
target_include_directories(Getopt-for-Visual-Studio INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/)

target_sources(Getopt-for-Visual-Studio
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/getopt.h)
target_sources(Getopt-for-Visual-Studio INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/getopt.h)
12 changes: 8 additions & 4 deletions 3rdParty/LightPcapNg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/LightPcapNg/cmake/")
option(LIGHT_PCAPNG_ZSTD "Build with ZSTD compression support" OFF)

add_library(
light_pcapng OBJECT
light_pcapng
OBJECT
LightPcapNg/src/light_advanced.c
LightPcapNg/src/light_alloc.c
LightPcapNg/src/light_compression.c
Expand All @@ -20,16 +21,19 @@ add_library(
LightPcapNg/src/light_pcapng_ext.c
LightPcapNg/src/light_pcapng.c
LightPcapNg/src/light_platform.c
LightPcapNg/src/light_zstd_compression.c)
LightPcapNg/src/light_zstd_compression.c
)

target_compile_definitions(light_pcapng PUBLIC -DUNIVERSAL)

if(BUILD_SHARED_LIBS)
set_property(TARGET light_pcapng PROPERTY POSITION_INDEPENDENT_CODE ON)
endif()

target_include_directories(light_pcapng PUBLIC $<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/LightPcapNg/include>)
target_include_directories(
light_pcapng
PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/LightPcapNg/include>
)

if(LIGHT_PCAPNG_ZSTD)
find_package(ZSTD)
Expand Down
150 changes: 66 additions & 84 deletions 3rdParty/LightPcapNg/LightPcapNg/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,84 +1,66 @@
cmake_minimum_required (VERSION 2.6)
project (light_pcapng C)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}/include/ -Wall -O2 -fPIC -DUNIVERSAL -g")

add_library (light_pcapng SHARED
src/light_io.c
src/light_pcapng.c
src/light_pcapng_cont.c
src/light_platform.c
src/light_manipulate.c
src/light_internal.c
src/light_alloc.c
src/light_advanced.c
src/light_option.c
src/light_pcapng_ext.c
)

add_library (light_pcapng_static STATIC
src/light_io.c
src/light_pcapng.c
src/light_pcapng_cont.c
src/light_platform.c
src/light_manipulate.c
src/light_internal.c
src/light_alloc.c
src/light_advanced.c
src/light_option.c
src/light_pcapng_ext.c
)

add_executable (test_read.test
src/tests/test_read.c
)
target_link_libraries(test_read.test light_pcapng_static)

add_executable (test_read_write.test
src/tests/test_read_write.c
)
target_link_libraries(test_read_write.test light_pcapng_static)

add_executable (test_mem.test
src/tests/test_mem.c
)
target_link_libraries(test_mem.test light_pcapng_static)

add_executable (test_histogram.test
src/tests/test_histogram.c
)
target_link_libraries(test_histogram.test light_pcapng_static)

add_executable (test_subcapture.test
src/tests/test_subcapture.c
)
target_link_libraries(test_subcapture.test light_pcapng_static)

add_executable (test_feature.test
src/tests/test_feature.c
)
target_link_libraries(test_feature.test light_pcapng_static)

add_executable (test_flow.test
src/tests/test_flow.c
)
target_link_libraries(test_flow.test light_pcapng_static)

add_executable (test_feature_advanced.test
src/tests/test_feature_advanced.c
)
target_link_libraries(test_feature_advanced.test light_pcapng_static dl)

add_executable (test_read_packets.test
src/tests/test_read_packets.c
)
target_link_libraries(test_read_packets.test light_pcapng_static)

add_executable (test_read_write_packets.test
src/tests/test_read_write_packets.c
)
target_link_libraries(test_read_write_packets.test light_pcapng_static)

add_executable (test_split.test
src/tests/test_split.c
)
target_link_libraries(test_split.test light_pcapng_static)
cmake_minimum_required(VERSION 2.6)
project(light_pcapng C)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}/include/ -Wall -O2 -fPIC -DUNIVERSAL -g")

add_library(
light_pcapng
SHARED
src/light_io.c
src/light_pcapng.c
src/light_pcapng_cont.c
src/light_platform.c
src/light_manipulate.c
src/light_internal.c
src/light_alloc.c
src/light_advanced.c
src/light_option.c
src/light_pcapng_ext.c
)

add_library(
light_pcapng_static
STATIC
src/light_io.c
src/light_pcapng.c
src/light_pcapng_cont.c
src/light_platform.c
src/light_manipulate.c
src/light_internal.c
src/light_alloc.c
src/light_advanced.c
src/light_option.c
src/light_pcapng_ext.c
)

add_executable(test_read.test src/tests/test_read.c)
target_link_libraries(test_read.test light_pcapng_static)

add_executable(test_read_write.test src/tests/test_read_write.c)
target_link_libraries(test_read_write.test light_pcapng_static)

add_executable(test_mem.test src/tests/test_mem.c)
target_link_libraries(test_mem.test light_pcapng_static)

add_executable(test_histogram.test src/tests/test_histogram.c)
target_link_libraries(test_histogram.test light_pcapng_static)

add_executable(test_subcapture.test src/tests/test_subcapture.c)
target_link_libraries(test_subcapture.test light_pcapng_static)

add_executable(test_feature.test src/tests/test_feature.c)
target_link_libraries(test_feature.test light_pcapng_static)

add_executable(test_flow.test src/tests/test_flow.c)
target_link_libraries(test_flow.test light_pcapng_static)

add_executable(test_feature_advanced.test src/tests/test_feature_advanced.c)
target_link_libraries(test_feature_advanced.test light_pcapng_static dl)

add_executable(test_read_packets.test src/tests/test_read_packets.c)
target_link_libraries(test_read_packets.test light_pcapng_static)

add_executable(test_read_write_packets.test src/tests/test_read_write_packets.c)
target_link_libraries(test_read_write_packets.test light_pcapng_static)

add_executable(test_split.test src/tests/test_split.c)
target_link_libraries(test_split.test light_pcapng_static)
2 changes: 1 addition & 1 deletion 3rdParty/LightPcapNg/LightPcapNg/LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
20 changes: 14 additions & 6 deletions 3rdParty/LightPcapNg/LightPcapNg/src/light_pcapng.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ void parse_by_block_type(struct _light_pcapng *current, const uint32_t *local_da
switch (current->block_type)
{
case LIGHT_SECTION_HEADER_BLOCK:
{
{ // PCPP patch
DPRINT_HERE(LIGHT_SECTION_HEADER_BLOCK);
struct _light_section_header *shb = calloc(1, sizeof(struct _light_section_header));
struct _light_option *opt = NULL;
uint32_t version;
int32_t local_offset;
uint32_t version = 0;
int32_t local_offset = 0;

shb->byteorder_magic = *local_data++;
// TODO check byte order.
Expand All @@ -108,30 +108,34 @@ void parse_by_block_type(struct _light_pcapng *current, const uint32_t *local_da
current->block_body = (uint32_t*)shb;
local_offset = (size_t)local_data - (size_t)block_start;
opt = __parse_options((uint32_t **)&local_data, current->block_total_length - local_offset - sizeof(current->block_total_length));
if (opt == NULL)
opt = calloc(1, sizeof(struct _light_option));
current->options = opt;
}
break;

case LIGHT_INTERFACE_BLOCK:
{
{ // PCPP patch
DPRINT_HERE(LIGHT_INTERFACE_BLOCK);
struct _light_interface_description_block *idb = calloc(1, sizeof(struct _light_interface_description_block));
struct _light_option *opt = NULL;
uint32_t link_reserved = *local_data++;
int32_t local_offset;
int32_t local_offset = 0;

idb->link_type = link_reserved & 0xFFFF;
idb->reserved = (link_reserved >> 16) & 0xFFFF;
idb->snapshot_length = *local_data++;
current->block_body = (uint32_t*)idb;
local_offset = (size_t)local_data - (size_t)block_start;
opt = __parse_options((uint32_t **)&local_data, current->block_total_length - local_offset - sizeof(current->block_total_length));
if (opt == NULL)
opt = calloc(1, sizeof(struct _light_option));
current->options = opt;
}
break;

case LIGHT_ENHANCED_PACKET_BLOCK:
{
{ // PCPP Patch
DPRINT_HERE(LIGHT_ENHANCED_PACKET_BLOCK);
struct _light_enhanced_packet_block *epb = NULL;
struct _light_option *opt = NULL;
Expand All @@ -157,6 +161,8 @@ void parse_by_block_type(struct _light_pcapng *current, const uint32_t *local_da
current->block_body = (uint32_t*)epb;
local_offset = (size_t)local_data - (size_t)block_start;
opt = __parse_options((uint32_t **)&local_data, current->block_total_length - local_offset - sizeof(current->block_total_length));
if (opt == NULL)
opt = calloc(1, sizeof(struct _light_option));
current->options = opt;
}
break;
Expand Down Expand Up @@ -200,6 +206,8 @@ void parse_by_block_type(struct _light_pcapng *current, const uint32_t *local_da
current->block_body = (uint32_t*)cnb;
local_offset = (size_t)local_data - (size_t)block_start;
opt = __parse_options((uint32_t **)&local_data, current->block_total_length - local_offset - sizeof(current->block_total_length));
if (opt == NULL)
opt = calloc(1, sizeof(struct _light_option));
current->options = opt;
}
break;
Expand Down
Loading

0 comments on commit 3c97bbb

Please sign in to comment.