test: add fuzzer for ClientHelloParser
Signed-off-by: Adam Korczynski <adam@adalogics.com> PR-URL: https://github.com/nodejs/node/pull/51088 Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
d9b61dbe89
commit
65573f4864
43
node.gyp
43
node.gyp
@ -1066,6 +1066,49 @@
|
|||||||
}],
|
}],
|
||||||
],
|
],
|
||||||
}, # fuzz_env
|
}, # fuzz_env
|
||||||
|
{ # fuzz_ClientHelloParser.cc
|
||||||
|
'target_name': 'fuzz_ClientHelloParser',
|
||||||
|
'type': 'executable',
|
||||||
|
'dependencies': [
|
||||||
|
'<(node_lib_target_name)',
|
||||||
|
'deps/histogram/histogram.gyp:histogram',
|
||||||
|
'deps/uvwasi/uvwasi.gyp:uvwasi',
|
||||||
|
],
|
||||||
|
'includes': [
|
||||||
|
'node.gypi'
|
||||||
|
],
|
||||||
|
'include_dirs': [
|
||||||
|
'src',
|
||||||
|
'tools/msvs/genfiles',
|
||||||
|
'deps/v8/include',
|
||||||
|
'deps/cares/include',
|
||||||
|
'deps/uv/include',
|
||||||
|
'deps/uvwasi/include',
|
||||||
|
'test/cctest',
|
||||||
|
],
|
||||||
|
'defines': [
|
||||||
|
'NODE_ARCH="<(target_arch)"',
|
||||||
|
'NODE_PLATFORM="<(OS)"',
|
||||||
|
'NODE_WANT_INTERNALS=1',
|
||||||
|
],
|
||||||
|
'sources': [
|
||||||
|
'src/node_snapshot_stub.cc',
|
||||||
|
'test/fuzzers/fuzz_ClientHelloParser.cc',
|
||||||
|
],
|
||||||
|
'conditions': [
|
||||||
|
['OS=="linux"', {
|
||||||
|
'ldflags': [ '-fsanitize=fuzzer' ]
|
||||||
|
}],
|
||||||
|
# Ensure that ossfuzz flag has been set and that we are on Linux
|
||||||
|
[ 'OS!="linux" or ossfuzz!="true"', {
|
||||||
|
'type': 'none',
|
||||||
|
}],
|
||||||
|
# Avoid excessive LTO
|
||||||
|
['enable_lto=="true"', {
|
||||||
|
'ldflags': [ '-fno-lto' ],
|
||||||
|
}],
|
||||||
|
],
|
||||||
|
}, # fuzz_ClientHelloParser.cc
|
||||||
{
|
{
|
||||||
'target_name': 'cctest',
|
'target_name': 'cctest',
|
||||||
'type': 'executable',
|
'type': 'executable',
|
||||||
|
16
test/fuzzers/fuzz_ClientHelloParser.cc
Normal file
16
test/fuzzers/fuzz_ClientHelloParser.cc
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* A fuzzer focused on node::crypto::ClientHelloParser.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "crypto/crypto_clienthello-inl.h"
|
||||||
|
|
||||||
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||||
|
node::crypto::ClientHelloParser parser;
|
||||||
|
bool end_cb_called = false;
|
||||||
|
parser.Start([](void* arg, auto hello) { },
|
||||||
|
[](void* arg) { },
|
||||||
|
&end_cb_called);
|
||||||
|
parser.Parse(data, size);
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user