[libFuzzer] make LLVMFuzzerTestOneInput (the fuzzer target function) return int inste...
authorKostya Serebryany <kcc@google.com>
Fri, 2 Oct 2015 23:34:06 +0000 (23:34 +0000)
committerKostya Serebryany <kcc@google.com>
Fri, 2 Oct 2015 23:34:06 +0000 (23:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249214 91177308-0d34-0410-b5e6-96231b3b80d8

23 files changed:
docs/LibFuzzer.rst
lib/Fuzzer/FuzzerInterface.h
lib/Fuzzer/FuzzerInternal.h
lib/Fuzzer/FuzzerLoop.cpp
lib/Fuzzer/FuzzerMain.cpp
lib/Fuzzer/test/CounterTest.cpp
lib/Fuzzer/test/CxxTokensTest.cpp
lib/Fuzzer/test/FourIndependentBranchesTest.cpp
lib/Fuzzer/test/FullCoverageSetTest.cpp
lib/Fuzzer/test/InfiniteTest.cpp
lib/Fuzzer/test/MemcmpTest.cpp
lib/Fuzzer/test/NullDerefTest.cpp
lib/Fuzzer/test/SimpleCmpTest.cpp
lib/Fuzzer/test/SimpleDictionaryTest.cpp
lib/Fuzzer/test/SimpleHashTest.cpp
lib/Fuzzer/test/SimpleTest.cpp
lib/Fuzzer/test/StrcmpTest.cpp
lib/Fuzzer/test/StrncmpTest.cpp
lib/Fuzzer/test/SwitchTest.cpp
lib/Fuzzer/test/TimeoutTest.cpp
lib/Fuzzer/test/UserSuppliedFuzzerTest.cpp
tools/llvm-as-fuzzer/llvm-as-fuzzer.cpp
tools/llvm-mc-fuzzer/llvm-mc-fuzzer.cpp

index 4155526ac8461a94816906c4b5223db76a4102d4..0c90a1d5429cafaf5586549598d3df585cb98432 100644 (file)
@@ -21,7 +21,8 @@ This library is intended primarily for in-process coverage-guided fuzz testing
   optimizations options (e.g. -O0, -O1, -O2) to diversify testing.
 * Build a test driver using the same options as the library.
   The test driver is a C/C++ file containing interesting calls to the library
-  inside a single function  ``extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);``
+  inside a single function  ``extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);``.
+  Currently, the only expected return value is 0, others are reserved for future.
 * Link the Fuzzer, the library and the driver together into an executable
   using the same sanitizer options as for the library.
 * Collect the initial corpus of inputs for the
@@ -83,11 +84,12 @@ Toy example
 A simple function that does something interesting if it receives the input "HI!"::
 
   cat << EOF >> test_fuzzer.cc
-  extern "C" void LLVMFuzzerTestOneInput(const unsigned char *data, unsigned long size) {
+  extern "C" int LLVMFuzzerTestOneInput(const unsigned char *data, unsigned long size) {
     if (size > 0 && data[0] == 'H')
       if (size > 1 && data[1] == 'I')
          if (size > 2 && data[2] == '!')
          __builtin_trap();
+    return 0;
   }
   EOF
   # Get lib/Fuzzer. Assuming that you already have fresh clang in PATH.
@@ -119,8 +121,8 @@ Here we show how to use lib/Fuzzer on something real, yet simple: pcre2_::
   cat << EOF > pcre_fuzzer.cc
   #include <string.h>
   #include "pcre2posix.h"
-  extern "C" void LLVMFuzzerTestOneInput(const unsigned char *data, size_t size) {
-    if (size < 1) return;
+  extern "C" int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size) {
+    if (size < 1) return 0;
     char *str = new char[size+1];
     memcpy(str, data, size);
     str[size] = 0;
@@ -130,6 +132,7 @@ Here we show how to use lib/Fuzzer on something real, yet simple: pcre2_::
       regfree(&preg);
     }
     delete [] str;
+    return 0;
   }
   EOF
   clang++ -g -fsanitize=address $COV_FLAGS -c -std=c++11  -I inst/include/ pcre_fuzzer.cc
@@ -227,7 +230,7 @@ to find Heartbleed with LibFuzzer::
     assert (SSL_CTX_use_PrivateKey_file(sctx, "server.key", SSL_FILETYPE_PEM));
     return 0;
   }
-  extern "C" void LLVMFuzzerTestOneInput(unsigned char *Data, size_t Size) {
+  extern "C" int LLVMFuzzerTestOneInput(unsigned char *Data, size_t Size) {
     static int unused = Init();
     SSL *server = SSL_new(sctx);
     BIO *sinbio = BIO_new(BIO_s_mem());
@@ -237,6 +240,7 @@ to find Heartbleed with LibFuzzer::
     BIO_write(sinbio, Data, Size);
     SSL_do_handshake(server);
     SSL_free(server);
+    return 0;
   }
   EOF
   # Build the fuzzer.
index 7f7d608800d166fa4703591716974fd4769af8eb..de5084222ef4539e317d5743f47bec329e15e573 100644 (file)
@@ -23,7 +23,9 @@
 
 namespace fuzzer {
 
-typedef void (*UserCallback)(const uint8_t *Data, size_t Size);
+typedef void (*DeprecatedUserCallback)(const uint8_t *Data, size_t Size);
+/// Returns an int 0. Values other than zero are reserved for future.
+typedef int (*UserCallback)(const uint8_t *Data, size_t Size);
 /** Simple C-like interface with a single user-supplied callback.
 
 Usage:
@@ -31,8 +33,9 @@ Usage:
 #\code
 #include "FuzzerInterface.h"
 
-void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   DoStuffWithData(Data, Size);
+  return 0;
 }
 
 // Implement your own main() or use the one from FuzzerMain.cpp.
@@ -43,6 +46,7 @@ int main(int argc, char **argv) {
 #\endcode
 */
 int FuzzerDriver(int argc, char **argv, UserCallback Callback);
+int FuzzerDriver(int argc, char **argv, DeprecatedUserCallback Callback);
 
 class FuzzerRandomBase {
  public:
@@ -118,7 +122,7 @@ class MyFuzzer : public fuzzer::UserSuppliedFuzzer {
  public:
   MyFuzzer(fuzzer::FuzzerRandomBase *Rand);
   // Must define the target function.
-  void TargetFunction(...) { ... }
+  int TargetFunction(...) { ...; return 0; }
   // Optionally define the mutator.
   size_t Mutate(...) { ... }
   // Optionally define the CrossOver method.
@@ -136,7 +140,7 @@ class UserSuppliedFuzzer {
   UserSuppliedFuzzer();  // Deprecated, don't use.
   UserSuppliedFuzzer(FuzzerRandomBase *Rand);
   /// Executes the target function on 'Size' bytes of 'Data'.
-  virtual void TargetFunction(const uint8_t *Data, size_t Size) = 0;
+  virtual int TargetFunction(const uint8_t *Data, size_t Size) = 0;
   /// Mutates 'Size' bytes of data in 'Data' inplace into up to 'MaxSize' bytes,
   /// returns the new size of the data, which should be positive.
   virtual size_t Mutate(uint8_t *Data, size_t Size, size_t MaxSize) {
index 78e9c2208b6c5d75c982de79be0500082d1774a2..3049167c62bc59b579f29ce3b6951b6b7c5fecad 100644 (file)
@@ -176,12 +176,19 @@ class SimpleUserSuppliedFuzzer: public UserSuppliedFuzzer {
  public:
   SimpleUserSuppliedFuzzer(FuzzerRandomBase *Rand, UserCallback Callback)
       : UserSuppliedFuzzer(Rand), Callback(Callback) {}
-  virtual void TargetFunction(const uint8_t *Data, size_t Size) {
-    return Callback(Data, Size);
+
+  SimpleUserSuppliedFuzzer(FuzzerRandomBase *Rand, DeprecatedUserCallback Callback)
+      : UserSuppliedFuzzer(Rand), DeprecatedCallback(Callback) {}
+
+  virtual int TargetFunction(const uint8_t *Data, size_t Size) override {
+    if (Callback) return Callback(Data, Size);
+    DeprecatedCallback(Data, Size);
+    return 0;
   }
 
  private:
-  UserCallback Callback;
+  DeprecatedUserCallback DeprecatedCallback = nullptr;
+  UserCallback Callback = nullptr;
 };
 
 };  // namespace fuzzer
index 62a47bf058159180f474e6dc64f65d361c2d0f57..bfeed1ab21e0e7e067b5a393c4211ffc788afc1c 100644 (file)
@@ -194,12 +194,14 @@ Unit Fuzzer::SubstituteTokens(const Unit &U) const {
 }
 
 void Fuzzer::ExecuteCallback(const Unit &U) {
+  int Res = 0;
   if (Options.Tokens.empty()) {
-    USF.TargetFunction(U.data(), U.size());
+    Res = USF.TargetFunction(U.data(), U.size());
   } else {
     auto T = SubstituteTokens(U);
-    USF.TargetFunction(T.data(), T.size());
+    Res = USF.TargetFunction(T.data(), T.size());
   }
+  assert(Res == 0);
 }
 
 size_t Fuzzer::RunOneMaximizeTotalCoverage(const Unit &U) {
index c4dffb45d166af62643e0368e04239c4c11337c6..c5af5b059091026ac0e5266ca8530a3ba72eac7d 100644 (file)
@@ -13,7 +13,7 @@
 #include "FuzzerInternal.h"
 
 // This function should be defined by the user.
-extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
 
 int main(int argc, char **argv) {
   return fuzzer::FuzzerDriver(argc, argv, LLVMFuzzerTestOneInput);
index 29ddb02ebaea3ecbbfc0163135d497a3d6fb0ab3..b61f419c4991f4fa38fb5728f9f5e99e31365d47 100644 (file)
@@ -2,7 +2,7 @@
 // executed many times.
 #include <iostream>
 
-extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   int Num = 0;
   for (size_t i = 0; i < Size; i++)
     if (Data[i] == 'A' + i)
@@ -11,4 +11,5 @@ extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
     std::cerr <<  "BINGO!\n";
     exit(1);
   }
+  return 0;
 }
index 77d08b3d105532d69497b47c7b59791cfcfe69f1..82773231569ab296d5eeef87271567d623f8b34a 100644 (file)
@@ -10,9 +10,9 @@ static void Found() {
   exit(1);
 }
 
-extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   // looking for "thread_local unsigned A;"
-  if (Size < 24) return;
+  if (Size < 24) return 0;
   if (0 == memcmp(&Data[0], "thread_local", 12))
     if (Data[12] == ' ')
       if (0 == memcmp(&Data[13], "unsigned", 8))
@@ -20,5 +20,6 @@ extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
           if (Data[22] == 'A')
             if (Data[23] == ';')
               Found();
+  return 0;
 }
 
index e0b7509b8d65f2865ed6bbf867c7f935380e9a7e..6007dd4a027b48d978b44a0a70ba35ca1769743b 100644 (file)
@@ -4,7 +4,7 @@
 #include <cstddef>
 #include <iostream>
 
-extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   int bits = 0;
   if (Size > 0 && Data[0] == 'F') bits |= 1;
   if (Size > 1 && Data[1] == 'U') bits |= 2;
@@ -14,5 +14,6 @@ extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
     std::cerr <<  "BINGO!\n";
     exit(1);
   }
+  return 0;
 }
 
index 2c6ff98db0055bc7e11a801c09db4105eb672cc2..a868084a0ceefeefc77a1bd19a58c899308a0d65 100644 (file)
@@ -4,7 +4,7 @@
 #include <cstddef>
 #include <iostream>
 
-extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   int bits = 0;
   if (Size > 0 && Data[0] == 'F') bits |= 1;
   if (Size > 1 && Data[1] == 'U') bits |= 2;
@@ -16,5 +16,6 @@ extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
     std::cerr <<  "BINGO!\n";
     exit(1);
   }
+  return 0;
 }
 
index b6d174ffdc90fb50d6e1e42ceec2af4888e526de..e3288eecfbaad55bd73f0e3479fa2ff8bc68a409 100644 (file)
@@ -8,7 +8,7 @@ static volatile int Sink;
 
 static volatile int One = 1;
 
-extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   if (Size > 0 && Data[0] == 'H') {
     Sink = 1;
     if (Size > 1 && Data[1] == 'i') {
@@ -20,5 +20,6 @@ extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
       }
     }
   }
+  return 0;
 }
 
index 2954b6c7d486127e64aadb0787b0f8eb5ab3500d..47ce59e0d8f55ed7d7c24a36626d2f8256da2302 100644 (file)
@@ -4,7 +4,7 @@
 #include <cstdio>
 #include <cstdlib>
 
-extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   // TODO: check other sizes.
   if (Size >= 8 && memcmp(Data, "01234567", 8) == 0) {
     if (Size >= 12 && memcmp(Data + 8, "ABCD", 4) == 0) {
@@ -16,4 +16,5 @@ extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
       }
     }
   }
+  return 0;
 }
index 0cff6617a31d07beca8781a4b6889276996d3e1f..200c56ccbbc900800e74b94f1dfcd00587206c35 100644 (file)
@@ -7,7 +7,7 @@
 static volatile int Sink;
 static volatile int *Null = 0;
 
-extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   if (Size > 0 && Data[0] == 'H') {
     Sink = 1;
     if (Size > 1 && Data[1] == 'i') {
@@ -18,5 +18,6 @@ extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
       }
     }
   }
+  return 0;
 }
 
index ee378146dae1de2754f0e8fc4c61c9e77e0b0d4c..8568c737efb1e6b0b123808a28729833cb6e4197 100644 (file)
@@ -4,8 +4,8 @@
 #include <cstring>
 #include <cstdio>
 
-extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
-  if (Size < 14) return;
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+  if (Size < 14) return 0;
   uint64_t x = 0;
   int64_t  y = 0;
   int z = 0;
@@ -27,4 +27,5 @@ extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
             Size, x, y, z, a);
     exit(1);
   }
+  return 0;
 }
index 20c80674366c579852625c7c78a744a6bd28532e..b9cb2f0270a33f72e1d328306be5c7b2f43d6b95 100644 (file)
@@ -10,9 +10,9 @@
 
 static volatile int Zero = 0;
 
-extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   const char *Expected = "ElvisPresley";
-  if (Size < strlen(Expected)) return;
+  if (Size < strlen(Expected)) return 0;
   size_t Match = 0;
   for (size_t i = 0; Expected[i]; i++)
     if (Expected[i] + Zero == Data[i])
@@ -21,5 +21,6 @@ extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
     std::cout << "BINGO; Found the target, exiting\n";
     exit(1);
   }
+  return 0;
 }
 
index a541d6813b5dabd46f6a64bdc6f6400b6ac700c6..5bab3fa7f6494e0992bfbe63b2ff208e2cbfade9 100644 (file)
@@ -22,15 +22,16 @@ static uint32_t simple_hash(const uint8_t *Data, size_t Size) {
   return Hash;
 }
 
-extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   if (Size < 14)
-    return;
+    return 0;
 
   uint32_t Hash = simple_hash(&Data[0], Size - 4);
   uint32_t Want = reinterpret_cast<const uint32_t *>(&Data[Size - 4])[0];
   if (Hash != Want)
-    return;
+    return 0;
   fprintf(stderr, "BINGO; simple_hash defeated: %x == %x\n", (unsigned int)Hash,
           (unsigned int)Want);
   exit(1);
+  return 0;
 }
index a891635a7f149ec39e72dce0dab6e17afcc6bf3f..6811d115d9604d3acfacd6d5a9158d790ce0c995 100644 (file)
@@ -6,7 +6,7 @@
 
 static volatile int Sink;
 
-extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   if (Size > 0 && Data[0] == 'H') {
     Sink = 1;
     if (Size > 1 && Data[1] == 'i') {
@@ -17,5 +17,6 @@ extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
       }
     }
   }
+  return 0;
 }
 
index 04264fa93fdee6d47ee6ec1c1f54fcbc45ac3347..835819ae2f451a50f4758645b555074e14a6f383 100644 (file)
@@ -16,7 +16,7 @@ bool Eq(const uint8_t *Data, size_t Size, const char *Str) {
   return res == 0;
 }
 
-extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   if (Eq(Data, Size, "AAA") &&
       Size >= 3 && Eq(Data + 3, Size - 3, "BBBB") &&
       Size >= 7 && Eq(Data + 7, Size - 7, "CCCCCC") &&
@@ -25,4 +25,5 @@ extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
     fprintf(stderr, "BINGO\n");
     exit(1);
   }
+  return 0;
 }
index 187a2fd66ba921e14cc43d66629bac3bc24f3613..55344d75e0b1f765aac0a34e24ca14301d16f700 100644 (file)
@@ -6,7 +6,7 @@
 
 static volatile int sink;
 
-extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   // TODO: check other sizes.
   char *S = (char*)Data;
   if (Size >= 8 && strncmp(S, "123", 8))
@@ -21,4 +21,5 @@ extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
       }
     }
   }
+  return 0;
 }
index 9f921fb6098628fc20363935c288836b19e8c281..5de7fff745257c4e38db36519cb904dfc3c504db 100644 (file)
@@ -42,7 +42,7 @@ bool ShortSwitch(const uint8_t *Data, size_t Size) {
   return false;
 }
 
-extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   if (Size >= 4  && Switch<int>(Data, Size) &&
       Size >= 12 && Switch<uint64_t>(Data + 4, Size - 4) &&
       Size >= 14 && ShortSwitch(Data + 12, 2)
@@ -50,5 +50,6 @@ extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
     fprintf(stderr, "BINGO; Found the target, exiting\n");
     exit(1);
   }
+  return 0;
 }
 
index d541c058b648f86105f91405184c5f0ba6f81b84..71790ded95a286c504e3e7ee56629ac2e336b47b 100644 (file)
@@ -6,7 +6,7 @@
 
 static volatile int Sink;
 
-extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   if (Size > 0 && Data[0] == 'H') {
     Sink = 1;
     if (Size > 1 && Data[1] == 'i') {
@@ -18,5 +18,6 @@ extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
       }
     }
   }
+  return 0;
 }
 
index 1e497cb28fa826542b08d8abd645ae067ae30dd1..59f83b57bfad671df06c0e9ace013fead51dfa4f 100644 (file)
@@ -16,9 +16,9 @@ class MyFuzzer : public fuzzer::UserSuppliedFuzzer {
  public:
   MyFuzzer(fuzzer::FuzzerRandomBase *Rand)
       : fuzzer::UserSuppliedFuzzer(Rand) {}
-  void TargetFunction(const uint8_t *Data, size_t Size) {
-    if (Size <= 10) return;
-    if (memcmp(Data, &kMagic, sizeof(kMagic))) return;
+  int TargetFunction(const uint8_t *Data, size_t Size) {
+    if (Size <= 10) return 0;
+    if (memcmp(Data, &kMagic, sizeof(kMagic))) return 0;
     // It's hard to get here w/o advanced fuzzing techniques (e.g. cmp tracing).
     // So, we simply 'fix' the data in the custom mutator.
     if (Data[8] == 'H') {
@@ -29,6 +29,7 @@ class MyFuzzer : public fuzzer::UserSuppliedFuzzer {
         }
       }
     }
+    return 0;
   }
   // Custom mutator.
   virtual size_t Mutate(uint8_t *Data, size_t Size, size_t MaxSize) {
index 47cea87cc37452bb94f24b3b32f8ac6e1216fbd4..b4024bcaa99ae68908a6b62ad6d4afc7698a15c9 100644 (file)
@@ -43,7 +43,7 @@ static bool InstalledHandler = false;
 
 } // end of anonymous namespace
 
-extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
 
   // Allocate space for locals before setjmp so that memory can be collected
   // if parse exits prematurely (via longjmp).
@@ -58,7 +58,7 @@ extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
 
   if (setjmp(JmpBuf))
     // If reached, we have returned with non-zero status, so exit.
-    return;
+    return 0;
 
   // TODO(kschimpf) Write a main to do this initialization.
   if (!InstalledHandler) {
@@ -69,7 +69,8 @@ extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   M = parseAssembly(MemBuf->getMemBufferRef(), Err, Context);
 
   if (!M.get())
-    return;
+    return 0;
 
   verifyModule(*M.get());
+  return 0;
 }
index 7710f80985dd2281df43195fe7dcfd750cf94590..3f80e4582ee1bc2e275a8677d4f535395c936717 100644 (file)
@@ -62,7 +62,7 @@ static cl::list<std::string>
                cl::desc("Options to pass to the fuzzer"), cl::ZeroOrMore,
                cl::PositionalEatsArgs);
 
-void DisassembleOneInput(const uint8_t *Data, size_t Size) {
+int DisassembleOneInput(const uint8_t *Data, size_t Size) {
   char AssemblyText[AssemblyTextBufSize];
 
   std::vector<uint8_t> DataCopy(Data, Data + Size);
@@ -85,6 +85,7 @@ void DisassembleOneInput(const uint8_t *Data, size_t Size) {
       break;
   } while (Consumed != 0);
   LLVMDisasmDispose(Ctx);
+  return 0;
 }
 
 int main(int argc, char **argv) {