Skip to content

Commit cd11aca

Browse files
authored
Merge branch 'dev' into patch-OSV-2024-947
2 parents c4c655a + 2d0fc5a commit cd11aca

File tree

131 files changed

+4498
-4871
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+4498
-4871
lines changed

.clang-tidy-new

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Checks: 'cert-*,
2+
clang-analyzer-*,
3+
concurrency-*,
4+
cppcoreguidelines-*,
5+
misc-*,
6+
modernize-*,
7+
performance-*,
8+
portability-*,
9+
readability-*,
10+
-cert-env33-c,
11+
-cert-err58-cpp,
12+
-clang-analyzer-optin.cplusplus.VirtualCall,
13+
-cppcoreguidelines-avoid-c-arrays,
14+
-cppcoreguidelines-avoid-do-while,
15+
-cppcoreguidelines-avoid-magic-numbers,
16+
-cppcoreguidelines-avoid-non-const-global-variables,
17+
-cppcoreguidelines-macro-usage,
18+
-cppcoreguidelines-owning-memory,
19+
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
20+
-cppcoreguidelines-pro-bounds-constant-array-index,
21+
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
22+
-cppcoreguidelines-pro-type-reinterpret-cast,
23+
-cppcoreguidelines-pro-type-const-cast,
24+
-cppcoreguidelines-pro-type-vararg,
25+
-cppcoreguidelines-special-member-functions,
26+
-modernize-avoid-c-arrays,
27+
-modernize-use-trailing-return-type,
28+
-misc-header-include-cycle,
29+
-misc-include-cleaner,
30+
-misc-no-recursion,
31+
-misc-non-private-member-variables-in-classes,
32+
-misc-use-anonymous-namespace,
33+
-readability-function-cognitive-complexity,
34+
-readability-magic-numbers'

.github/workflows/build_and_test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
apk update && apk add cppcheck python3-dev
3737
python3 -m venv .venv
3838
. .venv/bin/activate
39-
python3 -m pip install pre-commit setuptools clang-format==18.1.6 clang-tidy==18.1.8
39+
python3 -m pip install pre-commit setuptools clang-format==19.1.6 clang-tidy==18.1.8
4040
4141
- name: Run pre-commit
4242
run: |
@@ -701,7 +701,7 @@ jobs:
701701
./gradlew assembleDebug
702702
703703
xdp:
704-
runs-on: ubuntu-latest
704+
runs-on: ubuntu-22.04
705705

706706
steps:
707707
- name: Checkout code

.pre-commit-config.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
exclude: '.*\.(pcap|pcapng|dat|txt)'
1+
exclude: '.*\.(pcap|pcapng|dat)|(PacketExamples|PcapExamples|expected_output|pcap_examples).*\.txt'
22
fail_fast: false
33
repos:
44
- repo: local
@@ -22,7 +22,7 @@ repos:
2222
args: ['--fix=lf']
2323
- id: trailing-whitespace
2424
- repo: https://github.com/astral-sh/ruff-pre-commit
25-
rev: v0.8.1
25+
rev: v0.8.4
2626
hooks:
2727
- id: ruff # Run the linter.
2828
types_or: [ python ]
@@ -41,13 +41,14 @@ repos:
4141
rev: 0.17.1
4242
hooks:
4343
- id: gersemi
44+
args: ["-c"]
4445
- repo: https://github.com/codespell-project/codespell
4546
rev: v2.3.0
4647
hooks:
4748
- id: codespell
4849
pass_filenames: false
4950
- repo: https://github.com/crate-ci/typos
50-
rev: v1.28.1
51+
rev: codespell-dict-v0.5.0
5152
hooks:
5253
- id: typos
5354
args: ['--config=typos-config.toml']

3rdParty/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ if(PCAPPP_INSTALL)
1111
EXPORT PcapPlusPlusTargets
1212
ARCHIVE DESTINATION ${PCAPPP_INSTALL_LIBDIR}
1313
LIBRARY DESTINATION ${PCAPPP_INSTALL_LIBDIR}
14-
PUBLIC_HEADER DESTINATION ${PCAPPP_INSTALL_INCLUDEDIR})
14+
PUBLIC_HEADER DESTINATION ${PCAPPP_INSTALL_INCLUDEDIR}
15+
)
1516
endif()
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
add_library(EndianPortable INTERFACE)
22

3-
target_include_directories(EndianPortable
4-
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
3+
target_include_directories(EndianPortable INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
54

6-
target_sources(EndianPortable
7-
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include/EndianPortable.h)
5+
target_sources(EndianPortable INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include/EndianPortable.h)
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
add_library(Getopt-for-Visual-Studio INTERFACE)
22

3-
target_include_directories(Getopt-for-Visual-Studio
4-
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/)
3+
target_include_directories(Getopt-for-Visual-Studio INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/)
54

6-
target_sources(Getopt-for-Visual-Studio
7-
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/getopt.h)
5+
target_sources(Getopt-for-Visual-Studio INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/getopt.h)

3rdParty/LightPcapNg/CMakeLists.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/LightPcapNg/cmake/")
77
option(LIGHT_PCAPNG_ZSTD "Build with ZSTD compression support" OFF)
88

99
add_library(
10-
light_pcapng OBJECT
10+
light_pcapng
11+
OBJECT
1112
LightPcapNg/src/light_advanced.c
1213
LightPcapNg/src/light_alloc.c
1314
LightPcapNg/src/light_compression.c
@@ -20,16 +21,19 @@ add_library(
2021
LightPcapNg/src/light_pcapng_ext.c
2122
LightPcapNg/src/light_pcapng.c
2223
LightPcapNg/src/light_platform.c
23-
LightPcapNg/src/light_zstd_compression.c)
24+
LightPcapNg/src/light_zstd_compression.c
25+
)
2426

2527
target_compile_definitions(light_pcapng PUBLIC -DUNIVERSAL)
2628

2729
if(BUILD_SHARED_LIBS)
2830
set_property(TARGET light_pcapng PROPERTY POSITION_INDEPENDENT_CODE ON)
2931
endif()
3032

31-
target_include_directories(light_pcapng PUBLIC $<INSTALL_INTERFACE:include>
32-
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/LightPcapNg/include>)
33+
target_include_directories(
34+
light_pcapng
35+
PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/LightPcapNg/include>
36+
)
3337

3438
if(LIGHT_PCAPNG_ZSTD)
3539
find_package(ZSTD)
Lines changed: 66 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,66 @@
1-
cmake_minimum_required (VERSION 2.6)
2-
project (light_pcapng C)
3-
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}/include/ -Wall -O2 -fPIC -DUNIVERSAL -g")
4-
5-
add_library (light_pcapng SHARED
6-
src/light_io.c
7-
src/light_pcapng.c
8-
src/light_pcapng_cont.c
9-
src/light_platform.c
10-
src/light_manipulate.c
11-
src/light_internal.c
12-
src/light_alloc.c
13-
src/light_advanced.c
14-
src/light_option.c
15-
src/light_pcapng_ext.c
16-
)
17-
18-
add_library (light_pcapng_static STATIC
19-
src/light_io.c
20-
src/light_pcapng.c
21-
src/light_pcapng_cont.c
22-
src/light_platform.c
23-
src/light_manipulate.c
24-
src/light_internal.c
25-
src/light_alloc.c
26-
src/light_advanced.c
27-
src/light_option.c
28-
src/light_pcapng_ext.c
29-
)
30-
31-
add_executable (test_read.test
32-
src/tests/test_read.c
33-
)
34-
target_link_libraries(test_read.test light_pcapng_static)
35-
36-
add_executable (test_read_write.test
37-
src/tests/test_read_write.c
38-
)
39-
target_link_libraries(test_read_write.test light_pcapng_static)
40-
41-
add_executable (test_mem.test
42-
src/tests/test_mem.c
43-
)
44-
target_link_libraries(test_mem.test light_pcapng_static)
45-
46-
add_executable (test_histogram.test
47-
src/tests/test_histogram.c
48-
)
49-
target_link_libraries(test_histogram.test light_pcapng_static)
50-
51-
add_executable (test_subcapture.test
52-
src/tests/test_subcapture.c
53-
)
54-
target_link_libraries(test_subcapture.test light_pcapng_static)
55-
56-
add_executable (test_feature.test
57-
src/tests/test_feature.c
58-
)
59-
target_link_libraries(test_feature.test light_pcapng_static)
60-
61-
add_executable (test_flow.test
62-
src/tests/test_flow.c
63-
)
64-
target_link_libraries(test_flow.test light_pcapng_static)
65-
66-
add_executable (test_feature_advanced.test
67-
src/tests/test_feature_advanced.c
68-
)
69-
target_link_libraries(test_feature_advanced.test light_pcapng_static dl)
70-
71-
add_executable (test_read_packets.test
72-
src/tests/test_read_packets.c
73-
)
74-
target_link_libraries(test_read_packets.test light_pcapng_static)
75-
76-
add_executable (test_read_write_packets.test
77-
src/tests/test_read_write_packets.c
78-
)
79-
target_link_libraries(test_read_write_packets.test light_pcapng_static)
80-
81-
add_executable (test_split.test
82-
src/tests/test_split.c
83-
)
84-
target_link_libraries(test_split.test light_pcapng_static)
1+
cmake_minimum_required(VERSION 2.6)
2+
project(light_pcapng C)
3+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}/include/ -Wall -O2 -fPIC -DUNIVERSAL -g")
4+
5+
add_library(
6+
light_pcapng
7+
SHARED
8+
src/light_io.c
9+
src/light_pcapng.c
10+
src/light_pcapng_cont.c
11+
src/light_platform.c
12+
src/light_manipulate.c
13+
src/light_internal.c
14+
src/light_alloc.c
15+
src/light_advanced.c
16+
src/light_option.c
17+
src/light_pcapng_ext.c
18+
)
19+
20+
add_library(
21+
light_pcapng_static
22+
STATIC
23+
src/light_io.c
24+
src/light_pcapng.c
25+
src/light_pcapng_cont.c
26+
src/light_platform.c
27+
src/light_manipulate.c
28+
src/light_internal.c
29+
src/light_alloc.c
30+
src/light_advanced.c
31+
src/light_option.c
32+
src/light_pcapng_ext.c
33+
)
34+
35+
add_executable(test_read.test src/tests/test_read.c)
36+
target_link_libraries(test_read.test light_pcapng_static)
37+
38+
add_executable(test_read_write.test src/tests/test_read_write.c)
39+
target_link_libraries(test_read_write.test light_pcapng_static)
40+
41+
add_executable(test_mem.test src/tests/test_mem.c)
42+
target_link_libraries(test_mem.test light_pcapng_static)
43+
44+
add_executable(test_histogram.test src/tests/test_histogram.c)
45+
target_link_libraries(test_histogram.test light_pcapng_static)
46+
47+
add_executable(test_subcapture.test src/tests/test_subcapture.c)
48+
target_link_libraries(test_subcapture.test light_pcapng_static)
49+
50+
add_executable(test_feature.test src/tests/test_feature.c)
51+
target_link_libraries(test_feature.test light_pcapng_static)
52+
53+
add_executable(test_flow.test src/tests/test_flow.c)
54+
target_link_libraries(test_flow.test light_pcapng_static)
55+
56+
add_executable(test_feature_advanced.test src/tests/test_feature_advanced.c)
57+
target_link_libraries(test_feature_advanced.test light_pcapng_static dl)
58+
59+
add_executable(test_read_packets.test src/tests/test_read_packets.c)
60+
target_link_libraries(test_read_packets.test light_pcapng_static)
61+
62+
add_executable(test_read_write_packets.test src/tests/test_read_write_packets.c)
63+
target_link_libraries(test_read_write_packets.test light_pcapng_static)
64+
65+
add_executable(test_split.test src/tests/test_split.c)
66+
target_link_libraries(test_split.test light_pcapng_static)

3rdParty/LightPcapNg/LightPcapNg/LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
21+
SOFTWARE.

3rdParty/LightPcapNg/LightPcapNg/src/light_pcapng.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ void parse_by_block_type(struct _light_pcapng *current, const uint32_t *local_da
9090
switch (current->block_type)
9191
{
9292
case LIGHT_SECTION_HEADER_BLOCK:
93-
{
93+
{ // PCPP patch
9494
DPRINT_HERE(LIGHT_SECTION_HEADER_BLOCK);
9595
struct _light_section_header *shb = calloc(1, sizeof(struct _light_section_header));
9696
struct _light_option *opt = NULL;
97-
uint32_t version;
98-
int32_t local_offset;
97+
uint32_t version = 0;
98+
int32_t local_offset = 0;
9999

100100
shb->byteorder_magic = *local_data++;
101101
// TODO check byte order.
@@ -108,30 +108,34 @@ void parse_by_block_type(struct _light_pcapng *current, const uint32_t *local_da
108108
current->block_body = (uint32_t*)shb;
109109
local_offset = (size_t)local_data - (size_t)block_start;
110110
opt = __parse_options((uint32_t **)&local_data, current->block_total_length - local_offset - sizeof(current->block_total_length));
111+
if (opt == NULL)
112+
opt = calloc(1, sizeof(struct _light_option));
111113
current->options = opt;
112114
}
113115
break;
114116

115117
case LIGHT_INTERFACE_BLOCK:
116-
{
118+
{ // PCPP patch
117119
DPRINT_HERE(LIGHT_INTERFACE_BLOCK);
118120
struct _light_interface_description_block *idb = calloc(1, sizeof(struct _light_interface_description_block));
119121
struct _light_option *opt = NULL;
120122
uint32_t link_reserved = *local_data++;
121-
int32_t local_offset;
123+
int32_t local_offset = 0;
122124

123125
idb->link_type = link_reserved & 0xFFFF;
124126
idb->reserved = (link_reserved >> 16) & 0xFFFF;
125127
idb->snapshot_length = *local_data++;
126128
current->block_body = (uint32_t*)idb;
127129
local_offset = (size_t)local_data - (size_t)block_start;
128130
opt = __parse_options((uint32_t **)&local_data, current->block_total_length - local_offset - sizeof(current->block_total_length));
131+
if (opt == NULL)
132+
opt = calloc(1, sizeof(struct _light_option));
129133
current->options = opt;
130134
}
131135
break;
132136

133137
case LIGHT_ENHANCED_PACKET_BLOCK:
134-
{
138+
{ // PCPP Patch
135139
DPRINT_HERE(LIGHT_ENHANCED_PACKET_BLOCK);
136140
struct _light_enhanced_packet_block *epb = NULL;
137141
struct _light_option *opt = NULL;
@@ -157,6 +161,8 @@ void parse_by_block_type(struct _light_pcapng *current, const uint32_t *local_da
157161
current->block_body = (uint32_t*)epb;
158162
local_offset = (size_t)local_data - (size_t)block_start;
159163
opt = __parse_options((uint32_t **)&local_data, current->block_total_length - local_offset - sizeof(current->block_total_length));
164+
if (opt == NULL)
165+
opt = calloc(1, sizeof(struct _light_option));
160166
current->options = opt;
161167
}
162168
break;
@@ -200,6 +206,8 @@ void parse_by_block_type(struct _light_pcapng *current, const uint32_t *local_da
200206
current->block_body = (uint32_t*)cnb;
201207
local_offset = (size_t)local_data - (size_t)block_start;
202208
opt = __parse_options((uint32_t **)&local_data, current->block_total_length - local_offset - sizeof(current->block_total_length));
209+
if (opt == NULL)
210+
opt = calloc(1, sizeof(struct _light_option));
203211
current->options = opt;
204212
}
205213
break;

0 commit comments

Comments
 (0)