Jelajahi Sumber

Add a FuzzerClean() function

This allows to free everything we allocated, so we can detect memory
leaks.

Reviewed-by: Rich Salz <rsalz@openssl.org>
GH: #2023
Kurt Roeckx 7 tahun lalu
induk
melakukan
ad4da7fbc0
13 mengubah file dengan 47 tambahan dan 0 penghapusan
  1. 4 0
      fuzz/asn1.c
  2. 4 0
      fuzz/asn1parse.c
  3. 4 0
      fuzz/bignum.c
  4. 4 0
      fuzz/bndiv.c
  5. 4 0
      fuzz/cms.c
  6. 4 0
      fuzz/conf.c
  7. 4 0
      fuzz/crl.c
  8. 4 0
      fuzz/ct.c
  9. 2 0
      fuzz/driver.c
  10. 1 0
      fuzz/fuzzer.h
  11. 5 0
      fuzz/server.c
  12. 3 0
      fuzz/test-corpus.c
  13. 4 0
      fuzz/x509.c

+ 4 - 0
fuzz/asn1.c

@@ -222,3 +222,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
 
     return 0;
 }
+
+void FuzzerCleanup(void)
+{
+}

+ 4 - 0
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)
+{
+}

+ 4 - 0
fuzz/bignum.c

@@ -94,3 +94,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
 
     return 0;
 }
+
+void FuzzerCleanup(void)
+{
+}

+ 4 - 0
fuzz/bndiv.c

@@ -107,3 +107,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
 
     return 0;
 }
+
+void FuzzerCleanup(void)
+{
+}

+ 4 - 0
fuzz/cms.c

@@ -36,3 +36,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
     BIO_free(in);
     return 0;
 }
+
+void FuzzerCleanup(void)
+{
+}

+ 4 - 0
fuzz/conf.c

@@ -38,3 +38,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
 
     return 0;
 }
+
+void FuzzerCleanup(void)
+{
+}

+ 4 - 0
fuzz/crl.c

@@ -35,3 +35,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
     }
     return 0;
 }
+
+void FuzzerCleanup(void)
+{
+}

+ 4 - 0
fuzz/ct.c

@@ -40,3 +40,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
     }
     return 0;
 }
+
+void FuzzerCleanup(void)
+{
+}

+ 2 - 0
fuzz/driver.c

@@ -40,6 +40,8 @@ int main(int argc, char** argv)
         FuzzerTestOneInput(buf, size);
         free(buf);
     }
+
+    FuzzerCleanup();
     return 0;
 }
 

+ 1 - 0
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);

+ 5 - 0
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);
+}

+ 3 - 0
fuzz/test-corpus.c

@@ -42,5 +42,8 @@ int main(int argc, char **argv) {
         free(buf);
         fclose(f);
     }
+
+    FuzzerCleanup();
+
     return 0;
 }

+ 4 - 0
fuzz/x509.c

@@ -36,3 +36,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
     }
     return 0;
 }
+
+void FuzzerCleanup(void)
+{
+}