Skip to content

Commit 29ebeb5

Browse files
AdamKorczbmeck
authored andcommitted
test: add fuzzer for ClientHelloParser
Signed-off-by: Adam Korczynski <[email protected]> PR-URL: nodejs#51088 Reviewed-By: James M Snell <[email protected]>
1 parent 9b67766 commit 29ebeb5

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