提交 ba740700 编写于 作者: M Mike Aizatsky 提交者: Kurt Roeckx

[fuzzers] do not fail fuzzers with empty input

Reviewed-by: NKurt Roeckx <kurt@roeckx.be>
Reviewed-by: NRich Salz <rsalz@openssl.org>

GH: #1788
上级 e4d94269
......@@ -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);
......
......@@ -217,6 +217,12 @@ 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.
......@@ -224,9 +230,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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册