zstd_frame_info.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c) 2016-2021, Facebook, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under both the BSD-style license (found in the
  6. * LICENSE file in the root directory of this source tree) and the GPLv2 (found
  7. * in the COPYING file in the root directory of this source tree).
  8. * You may select, at your option, one of the above-listed licenses.
  9. */
  10. /**
  11. * This fuzz target fuzzes all of the helper functions that consume compressed
  12. * input.
  13. */
  14. #include <stddef.h>
  15. #include <stdlib.h>
  16. #include <stdio.h>
  17. #include "fuzz_helpers.h"
  18. #include "zstd_helpers.h"
  19. int LLVMFuzzerTestOneInput(const uint8_t *src, size_t size)
  20. {
  21. ZSTD_frameHeader zfh;
  22. if (size == 0) {
  23. src = NULL;
  24. }
  25. /* You can fuzz any helper functions here that are fast, and take zstd
  26. * compressed data as input. E.g. don't expect the input to be a dictionary,
  27. * so don't fuzz ZSTD_getDictID_fromDict().
  28. */
  29. ZSTD_getFrameContentSize(src, size);
  30. ZSTD_getDecompressedSize(src, size);
  31. ZSTD_findFrameCompressedSize(src, size);
  32. ZSTD_getDictID_fromFrame(src, size);
  33. ZSTD_findDecompressedSize(src, size);
  34. ZSTD_decompressBound(src, size);
  35. ZSTD_frameHeaderSize(src, size);
  36. ZSTD_isFrame(src, size);
  37. ZSTD_getFrameHeader(&zfh, src, size);
  38. ZSTD_getFrameHeader_advanced(&zfh, src, size, ZSTD_f_zstd1);
  39. return 0;
  40. }