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