X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=fuzz%2Fserver.c;h=b8a3ac44e382a11b2d5fe88b1b1caaaa1087f5af;hp=34c77340e8751ed84e1afd2ba6af7c6b74d0439d;hb=ad4da7fbc0779fb1730c9862221e19583de69f4f;hpb=90d28f0519427ffc293f880c423d9c4395a6fcd4 diff --git a/fuzz/server.c b/fuzz/server.c index 34c77340e8..b8a3ac44e3 100644 --- a/fuzz/server.c +++ b/fuzz/server.c @@ -15,6 +15,7 @@ #include #include +#include #include "fuzzer.h" static const uint8_t kCertificateDER[] = { @@ -190,7 +191,8 @@ static const uint8_t kRSAPrivateKeyDER[] = { static SSL_CTX *ctx; -int FuzzerInitialize(int *argc, char ***argv) { +int FuzzerInitialize(int *argc, char ***argv) +{ const uint8_t *bufp = kRSAPrivateKeyDER; RSA *privkey; EVP_PKEY *pkey; @@ -215,7 +217,14 @@ int FuzzerInitialize(int *argc, char ***argv) { return 1; } -int FuzzerTestOneInput(const uint8_t *buf, size_t len) { +int FuzzerTestOneInput(const uint8_t *buf, size_t len) +{ + SSL *server; + BIO *in; + BIO *out; + if (!len) { + return 0; + } /* TODO: make this work for OpenSSL. There's a PREDICT define that may do * the job. * TODO: use the ossltest engine (optionally?) to disable crypto checks. @@ -223,9 +232,9 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len) { */ /* This only fuzzes the initial flow from the client so far. */ - SSL *server = SSL_new(ctx); - BIO *in = BIO_new(BIO_s_mem()); - BIO *out = BIO_new(BIO_s_mem()); + server = SSL_new(ctx); + in = BIO_new(BIO_s_mem()); + out = BIO_new(BIO_s_mem()); SSL_set_bio(server, in, out); SSL_set_accept_state(server); OPENSSL_assert((size_t)BIO_write(in, buf, len) == len); @@ -241,3 +250,8 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len) { SSL_free(server); return 0; } + +void FuzzerCleanup(void) +{ + SSL_CTX_free(ctx); +}