From: Kurt Roeckx Date: Sat, 19 Nov 2016 16:13:10 +0000 (+0100) Subject: Add a FuzzerClean() function X-Git-Tag: OpenSSL_1_1_1-pre1~2947 X-Git-Url: https://git.openssl.org/?p=openssl.git;a=commitdiff_plain;h=ad4da7fbc0779fb1730c9862221e19583de69f4f Add a FuzzerClean() function This allows to free everything we allocated, so we can detect memory leaks. Reviewed-by: Rich Salz GH: #2023 --- diff --git a/fuzz/asn1.c b/fuzz/asn1.c index 0644ed79e1..f7b5571d4f 100644 --- a/fuzz/asn1.c +++ b/fuzz/asn1.c @@ -222,3 +222,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len) return 0; } + +void FuzzerCleanup(void) +{ +} diff --git a/fuzz/asn1parse.c b/fuzz/asn1parse.c index 2fba1c44b6..edb4d02303 100644 --- a/fuzz/asn1parse.c +++ b/fuzz/asn1parse.c @@ -33,3 +33,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len) (void)ASN1_parse_dump(bio_out, buf, len, 0, 0); return 0; } + +void FuzzerCleanup(void) +{ +} diff --git a/fuzz/bignum.c b/fuzz/bignum.c index 9e110f65ef..d6e8637a98 100644 --- a/fuzz/bignum.c +++ b/fuzz/bignum.c @@ -94,3 +94,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len) return 0; } + +void FuzzerCleanup(void) +{ +} diff --git a/fuzz/bndiv.c b/fuzz/bndiv.c index 9319878607..eb17f29cab 100644 --- a/fuzz/bndiv.c +++ b/fuzz/bndiv.c @@ -107,3 +107,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len) return 0; } + +void FuzzerCleanup(void) +{ +} diff --git a/fuzz/cms.c b/fuzz/cms.c index 71d8b6953c..c4477efa8f 100644 --- a/fuzz/cms.c +++ b/fuzz/cms.c @@ -36,3 +36,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len) BIO_free(in); return 0; } + +void FuzzerCleanup(void) +{ +} diff --git a/fuzz/conf.c b/fuzz/conf.c index 49edb3eaa6..27429c570f 100644 --- a/fuzz/conf.c +++ b/fuzz/conf.c @@ -38,3 +38,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len) return 0; } + +void FuzzerCleanup(void) +{ +} diff --git a/fuzz/crl.c b/fuzz/crl.c index 51d184363a..decf19e9d3 100644 --- a/fuzz/crl.c +++ b/fuzz/crl.c @@ -35,3 +35,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len) } return 0; } + +void FuzzerCleanup(void) +{ +} diff --git a/fuzz/ct.c b/fuzz/ct.c index 636b195109..47b0fc3f78 100644 --- a/fuzz/ct.c +++ b/fuzz/ct.c @@ -40,3 +40,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len) } return 0; } + +void FuzzerCleanup(void) +{ +} diff --git a/fuzz/driver.c b/fuzz/driver.c index d4b11cd6a4..21bbb255af 100644 --- a/fuzz/driver.c +++ b/fuzz/driver.c @@ -40,6 +40,8 @@ int main(int argc, char** argv) FuzzerTestOneInput(buf, size); free(buf); } + + FuzzerCleanup(); return 0; } diff --git a/fuzz/fuzzer.h b/fuzz/fuzzer.h index 04d605d79a..5f9efa4bf6 100644 --- a/fuzz/fuzzer.h +++ b/fuzz/fuzzer.h @@ -10,3 +10,4 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len); int FuzzerInitialize(int *argc, char ***argv); +void FuzzerCleanup(void); diff --git a/fuzz/server.c b/fuzz/server.c index 26ef4da1e6..b8a3ac44e3 100644 --- a/fuzz/server.c +++ b/fuzz/server.c @@ -250,3 +250,8 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len) SSL_free(server); return 0; } + +void FuzzerCleanup(void) +{ + SSL_CTX_free(ctx); +} diff --git a/fuzz/test-corpus.c b/fuzz/test-corpus.c index c553697d6c..9cef01f86d 100644 --- a/fuzz/test-corpus.c +++ b/fuzz/test-corpus.c @@ -42,5 +42,8 @@ int main(int argc, char **argv) { free(buf); fclose(f); } + + FuzzerCleanup(); + return 0; } diff --git a/fuzz/x509.c b/fuzz/x509.c index 4c5b73258d..78fef6c3ff 100644 --- a/fuzz/x509.c +++ b/fuzz/x509.c @@ -36,3 +36,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len) } return 0; } + +void FuzzerCleanup(void) +{ +}