182323fdcem/*
282323fdcem * Copyright (c) 2016-present, Facebook, Inc.
382323fdcem * All rights reserved.
482323fdcem *
582323fdcem * This source code is licensed under both the BSD-style license (found in the
682323fdcem * LICENSE file in the root directory of this source tree) and the GPLv2 (found
782323fdcem * in the COPYING file in the root directory of this source tree).
882323fdcem */
982323fdcem
1082323fdcem/**
1182323fdcem * This fuzz target fuzzes all of the helper functions that consume compressed
1282323fdcem * input.
1382323fdcem */
1482323fdcem
1582323fdcem#include <stddef.h>
1682323fdcem#include <stdlib.h>
1782323fdcem#include <stdio.h>
1882323fdcem#include "fuzz_helpers.h"
1982323fdcem#include "zstd_helpers.h"
2082323fdcem
2182323fdcemint LLVMFuzzerTestOneInput(const uint8_t *src, size_t size)
2282323fdcem{
2382323fdcem    ZSTD_frameHeader zfh;
2482323fdcem    /* You can fuzz any helper functions here that are fast, and take zstd
2582323fdcem     * compressed data as input. E.g. don't expect the input to be a dictionary,
2682323fdcem     * so don't fuzz ZSTD_getDictID_fromDict().
2782323fdcem     */
2882323fdcem    ZSTD_getFrameContentSize(src, size);
2982323fdcem    ZSTD_getDecompressedSize(src, size);
3082323fdcem    ZSTD_findFrameCompressedSize(src, size);
3182323fdcem    ZSTD_getDictID_fromFrame(src, size);
3282323fdcem    ZSTD_findDecompressedSize(src, size);
3382323fdcem    ZSTD_decompressBound(src, size);
3482323fdcem    ZSTD_frameHeaderSize(src, size);
3582323fdcem    ZSTD_isFrame(src, size);
3682323fdcem    ZSTD_getFrameHeader(&zfh, src, size);
3782323fdcem    ZSTD_getFrameHeader_advanced(&zfh, src, size, ZSTD_f_zstd1);
3882323fdcem    return 0;
3982323fdcem}
40