sog.cpp 858 B

123456789101112131415161718192021222324252627
  1. #include "WallpaperEngine/Splat/SogLoader.h"
  2. #include <cstring>
  3. #include <string>
  4. using namespace WallpaperEngine::Splat;
  5. // the first two bytes give the length of the meta JSON, whatever follows is what every file of the cloud reads as
  6. extern "C" int LLVMFuzzerTestOneInput (const uint8_t* data, size_t size) {
  7. if (size < 2) {
  8. return 0;
  9. }
  10. const size_t metaSize = std::min<size_t> ((data[0] | (data[1] << 8)), size - 2);
  11. const std::string meta (reinterpret_cast<const char*> (data) + 2, metaSize);
  12. const std::string payload (reinterpret_cast<const char*> (data) + 2 + metaSize, size - 2 - metaSize);
  13. try {
  14. std::ignore = loadSog (meta, [&] (const std::string&) { return payload; });
  15. } catch (const std::exception&) { }
  16. try {
  17. std::ignore = decodeWebP (payload);
  18. } catch (const std::exception&) { }
  19. return 0;
  20. }