Skip to content

Commit 5f6415b

Browse files
AdamKorcztargos
authored andcommitted
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 4d50d51 commit 5f6415b

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
@@ -1067,6 +1067,49 @@
10671067
}],
10681068
],
10691069
}, # fuzz_env
1070+
{ # fuzz_ClientHelloParser.cc
1071+
'target_name': 'fuzz_ClientHelloParser',
1072+
'type': 'executable',
1073+
'dependencies': [
1074+
'<(node_lib_target_name)',
1075+
'deps/histogram/histogram.gyp:histogram',
1076+
'deps/uvwasi/uvwasi.gyp:uvwasi',
1077+
],
1078+
'includes': [
1079+
'node.gypi'
1080+
],
1081+
'include_dirs': [
1082+
'src',
1083+
'tools/msvs/genfiles',
1084+
'deps/v8/include',
1085+
'deps/cares/include',
1086+
'deps/uv/include',
1087+
'deps/uvwasi/include',
1088+
'test/cctest',
1089+
],
1090+
'defines': [
1091+
'NODE_ARCH="<(target_arch)"',
1092+
'NODE_PLATFORM="<(OS)"',
1093+
'NODE_WANT_INTERNALS=1',
1094+
],
1095+
'sources': [
1096+
'src/node_snapshot_stub.cc',
1097+
'test/fuzzers/fuzz_ClientHelloParser.cc',
1098+
],
1099+
'conditions': [
1100+
['OS=="linux"', {
1101+
'ldflags': [ '-fsanitize=fuzzer' ]
1102+
}],
1103+
# Ensure that ossfuzz flag has been set and that we are on Linux
1104+
[ 'OS!="linux" or ossfuzz!="true"', {
1105+
'type': 'none',
1106+
}],
1107+
# Avoid excessive LTO
1108+
['enable_lto=="true"', {
1109+
'ldflags': [ '-fno-lto' ],
1110+
}],
1111+
],
1112+
}, # fuzz_ClientHelloParser.cc
10701113
{
10711114
'target_name': 'cctest',
10721115
'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)