unpack_pack_fuzzer.cpp 1.2 KB

1234567891011121314151617181920212223
  1. #include <msgpack.hpp>
  2. extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
  3. try {
  4. // NOTE(derwolfe): by default the limits are set at 2^32-1 length. I'm
  5. // setting these at far smaller values to avoid OOMs
  6. const int test_limit = 1000;
  7. msgpack::object_handle unpacked = msgpack::unpack(reinterpret_cast<const char *>(data),
  8. size,
  9. nullptr,
  10. nullptr,
  11. msgpack::unpack_limit(test_limit,
  12. test_limit,
  13. test_limit,
  14. test_limit,
  15. test_limit,
  16. test_limit));
  17. msgpack::sbuffer sbuf;
  18. msgpack::pack(sbuf, unpacked.get());
  19. } catch (...) {
  20. }
  21. return 0;
  22. }