Skip to content

Commit 5fb829b

Browse files
AdamKorczmarco-ippolito
authored andcommittedJun 17, 2024
test: add fuzzer for ClientHelloParser
Signed-off-by: Adam Korczynski <adam@adalogics.com> PR-URL: #51088 Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent cc74bf7 commit 5fb829b

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed
 

‎node.gyp

+43
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,49 @@
10491049
}],
10501050
],
10511051
}, # fuzz_env
1052+
{ # fuzz_ClientHelloParser.cc
1053+
'target_name': 'fuzz_ClientHelloParser',
1054+
'type': 'executable',
1055+
'dependencies': [
1056+
'<(node_lib_target_name)',
1057+
'deps/histogram/histogram.gyp:histogram',
1058+
'deps/uvwasi/uvwasi.gyp:uvwasi',
1059+
],
1060+
'includes': [
1061+
'node.gypi'
1062+
],
1063+
'include_dirs': [
1064+
'src',
1065+
'tools/msvs/genfiles',
1066+
'deps/v8/include',
1067+
'deps/cares/include',
1068+
'deps/uv/include',
1069+
'deps/uvwasi/include',
1070+
'test/cctest',
1071+
],
1072+
'defines': [
1073+
'NODE_ARCH="<(target_arch)"',
1074+
'NODE_PLATFORM="<(OS)"',
1075+
'NODE_WANT_INTERNALS=1',
1076+
],
1077+
'sources': [
1078+
'src/node_snapshot_stub.cc',
1079+
'test/fuzzers/fuzz_ClientHelloParser.cc',
1080+
],
1081+
'conditions': [
1082+
['OS=="linux"', {
1083+
'ldflags': [ '-fsanitize=fuzzer' ]
1084+
}],
1085+
# Ensure that ossfuzz flag has been set and that we are on Linux
1086+
[ 'OS!="linux" or ossfuzz!="true"', {
1087+
'type': 'none',
1088+
}],
1089+
# Avoid excessive LTO
1090+
['enable_lto=="true"', {
1091+
'ldflags': [ '-fno-lto' ],
1092+
}],
1093+
],
1094+
}, # fuzz_ClientHelloParser.cc
10521095
{
10531096
'target_name': 'cctest',
10541097
'type': 'executable',
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* A fuzzer focused on node::crypto::ClientHelloParser.
3+
*/
4+
5+
#include <stdlib.h>
6+
#include "crypto/crypto_clienthello-inl.h"
7+
8+
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
9+
node::crypto::ClientHelloParser parser;
10+
bool end_cb_called = false;
11+
parser.Start([](void* arg, auto hello) { },
12+
[](void* arg) { },
13+
&end_cb_called);
14+
parser.Parse(data, size);
15+
return 0;
16+
}

0 commit comments

Comments
 (0)
Please sign in to comment.