Skip to content

Commit

Permalink
Merge pull request grpc#9896 from matt-kwong/ssl-fuzz2
Browse files Browse the repository at this point in the history
Embed mock SSL data into ssl_server_fuzzer.c and add fuzzer options
  • Loading branch information
matt-kwong authored Mar 15, 2017
2 parents cedfa76 + d9b257a commit 5992c19
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 11 deletions.
2 changes: 1 addition & 1 deletion test/core/security/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer")
grpc_fuzzer(
name = "ssl_server_fuzzer",
srcs = ["ssl_server_fuzzer.c"],
deps = ["//:gpr", "//:grpc", "//test/core/util:grpc_test_util"],
deps = ["//:gpr", "//:grpc", "//test/core/util:grpc_test_util", "//test/core/end2end:ssl_test_data"],
corpus = "corpus",
copts = ["-std=c99"],
)
Expand Down
14 changes: 4 additions & 10 deletions test/core/security/ssl_server_fuzzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "src/core/lib/iomgr/load_file.h"
#include "src/core/lib/security/credentials/credentials.h"
#include "src/core/lib/security/transport/security_connector.h"
#include "test/core/end2end/data/ssl_test_data.h"
#include "test/core/util/memory_counters.h"
#include "test/core/util/mock_endpoint.h"

Expand All @@ -46,10 +47,6 @@ bool squelch = true;
// Turning this on will fail the leak check.
bool leak_check = false;

#define SSL_CERT_PATH "src/core/lib/tsi/test_creds/server1.pem"
#define SSL_KEY_PATH "src/core/lib/tsi/test_creds/server1.key"
#define SSL_CA_PATH "src/core/lib/tsi/test_creds/ca.pem"

static void discard_write(grpc_slice slice) {}

static void dont_log(gpr_log_func_args *args) {}
Expand Down Expand Up @@ -88,12 +85,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
// Load key pair and establish server SSL credentials.
grpc_ssl_pem_key_cert_pair pem_key_cert_pair;
grpc_slice ca_slice, cert_slice, key_slice;
GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file",
grpc_load_file(SSL_CA_PATH, 1, &ca_slice)));
GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file",
grpc_load_file(SSL_CERT_PATH, 1, &cert_slice)));
GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file",
grpc_load_file(SSL_KEY_PATH, 1, &key_slice)));
ca_slice = grpc_slice_from_static_string(test_root_cert);
cert_slice = grpc_slice_from_static_string(test_server1_cert);
key_slice = grpc_slice_from_static_string(test_server1_key);
const char *ca_cert = (const char *)GRPC_SLICE_START_PTR(ca_slice);
pem_key_cert_pair.private_key = (const char *)GRPC_SLICE_START_PTR(key_slice);
pem_key_cert_pair.cert_chain = (const char *)GRPC_SLICE_START_PTR(cert_slice);
Expand Down
3 changes: 3 additions & 0 deletions tools/fuzzer/options/api_fuzzer.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[libfuzzer]
max_len = 2048
dict = api_fuzzer.dictionary
3 changes: 3 additions & 0 deletions tools/fuzzer/options/client_fuzzer.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[libfuzzer]
max_len = 2048
dict = hpack.dictionary
2 changes: 2 additions & 0 deletions tools/fuzzer/options/fuzzer.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[libfuzzer]
max_len = 512
2 changes: 2 additions & 0 deletions tools/fuzzer/options/fuzzer_response.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[libfuzzer]
max_len = 128
2 changes: 2 additions & 0 deletions tools/fuzzer/options/fuzzer_serverlist.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[libfuzzer]
max_len = 128
3 changes: 3 additions & 0 deletions tools/fuzzer/options/hpack_parser_fuzzer_test.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[libfuzzer]
max_len = 512
dict = hpack.dictionary
2 changes: 2 additions & 0 deletions tools/fuzzer/options/percent_decode_fuzzer.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[libfuzzer]
max_len = 32
2 changes: 2 additions & 0 deletions tools/fuzzer/options/percent_encode_fuzzer.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[libfuzzer]
max_len = 32
3 changes: 3 additions & 0 deletions tools/fuzzer/options/request_fuzzer.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[libfuzzer]
max_len = 2048

3 changes: 3 additions & 0 deletions tools/fuzzer/options/response_fuzzer.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[libfuzzer]
max_len = 2048

3 changes: 3 additions & 0 deletions tools/fuzzer/options/server_fuzzer.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[libfuzzer]
max_len = 2048
dict = hpack.dictionary
2 changes: 2 additions & 0 deletions tools/fuzzer/options/ssl_server_fuzzer.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[libfuzzer]
max_len = 2048
2 changes: 2 additions & 0 deletions tools/fuzzer/options/uri_fuzzer_test.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[libfuzzer]
max_len = 128

0 comments on commit 5992c19

Please sign in to comment.