Skip to content

Commit a1cf25f

Browse files
committed
test: add fuzzer for ClientHelloParser
Signed-off-by: Adam Korczynski <[email protected]>
1 parent 8cdb7ca commit a1cf25f

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

node.gyp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,49 @@
10391039
}],
10401040
],
10411041
}, # fuzz_env
1042+
{ # fuzz_ClientHelloParser.cc
1043+
'target_name': 'fuzz_ClientHelloParser',
1044+
'type': 'executable',
1045+
'dependencies': [
1046+
'<(node_lib_target_name)',
1047+
'deps/histogram/histogram.gyp:histogram',
1048+
'deps/uvwasi/uvwasi.gyp:uvwasi',
1049+
],
1050+
'includes': [
1051+
'node.gypi'
1052+
],
1053+
'include_dirs': [
1054+
'src',
1055+
'tools/msvs/genfiles',
1056+
'deps/v8/include',
1057+
'deps/cares/include',
1058+
'deps/uv/include',
1059+
'deps/uvwasi/include',
1060+
'test/cctest',
1061+
],
1062+
'defines': [
1063+
'NODE_ARCH="<(target_arch)"',
1064+
'NODE_PLATFORM="<(OS)"',
1065+
'NODE_WANT_INTERNALS=1',
1066+
],
1067+
'sources': [
1068+
'src/node_snapshot_stub.cc',
1069+
'test/fuzzers/fuzz_ClientHelloParser.cc',
1070+
],
1071+
'conditions': [
1072+
['OS=="linux"', {
1073+
'ldflags': [ '-fsanitize=fuzzer' ]
1074+
}],
1075+
# Ensure that ossfuzz flag has been set and that we are on Linux
1076+
[ 'OS!="linux" or ossfuzz!="true"', {
1077+
'type': 'none',
1078+
}],
1079+
# Avoid excessive LTO
1080+
['enable_lto=="true"', {
1081+
'ldflags': [ '-fno-lto' ],
1082+
}],
1083+
],
1084+
}, # fuzz_ClientHelloParser.cc
10421085
{
10431086
'target_name': 'cctest',
10441087
'type': 'executable',
Lines changed: 16 additions & 0 deletions
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)