Skip to content

Commit

Permalink
[fuzzers] do not fail fuzzers with empty input
Browse files Browse the repository at this point in the history
Reviewed-by: Kurt Roeckx <[email protected]>
Reviewed-by: Rich Salz <[email protected]>

GH: openssl#1788
  • Loading branch information
aizatsky-at-google authored and kroeckx committed Nov 1, 2016
1 parent e4d9426 commit ba74070
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
6 changes: 5 additions & 1 deletion fuzz/cms.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ int FuzzerInitialize(int *argc, char ***argv) {

int FuzzerTestOneInput(const uint8_t *buf, size_t len) {
CMS_ContentInfo *i;
BIO *in = BIO_new(BIO_s_mem());
BIO *in;
if (!len) {
return 0;
}

in = BIO_new(BIO_s_mem());
OPENSSL_assert((size_t)BIO_write(in, buf, len) == len);
i = d2i_CMS_bio(in, NULL);
CMS_ContentInfo_free(i);
Expand Down
12 changes: 9 additions & 3 deletions fuzz/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,16 +217,22 @@ int FuzzerInitialize(int *argc, char ***argv) {
}

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.
* RAND_reset_for_fuzzing();
*/

/* 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);
Expand Down

0 comments on commit ba74070

Please sign in to comment.