Coverage Report

Created: 2025-08-29 07:00

/src/xz/tests/ossfuzz/fuzz_decode_alone.c
Line
Count
Source (jump to first uncovered line)
1
// SPDX-License-Identifier: 0BSD
2
3
///////////////////////////////////////////////////////////////////////////////
4
//
5
/// \file       fuzz_decode_alone.c
6
/// \brief      Fuzz test program for liblzma .lzma decoding
7
//
8
//  Authors:    Maksym Vatsyk
9
//              Lasse Collin
10
//
11
///////////////////////////////////////////////////////////////////////////////
12
13
#include <inttypes.h>
14
#include <stdlib.h>
15
#include <stdio.h>
16
#include "lzma.h"
17
#include "fuzz_common.h"
18
19
20
extern int
21
LLVMFuzzerTestOneInput(const uint8_t *inbuf, size_t inbuf_size)
22
13.7k
{
23
13.7k
  lzma_stream strm = LZMA_STREAM_INIT;
24
  // Initialize a LZMA alone decoder using the memory usage limit
25
  // defined in fuzz_common.h
26
13.7k
  lzma_ret ret = lzma_alone_decoder(&strm, MEM_LIMIT);
27
28
13.7k
  if (ret != LZMA_OK) {
29
    // This should never happen unless the system has
30
    // no free memory or address space to allow the small
31
    // allocations that the initialization requires.
32
0
    fprintf(stderr, "lzma_alone_decoder() failed (%d)\n", ret);
33
0
    abort();
34
0
  }
35
36
13.7k
  fuzz_code(&strm, inbuf, inbuf_size);
37
38
  // Free the allocated memory.
39
13.7k
  lzma_end(&strm);
40
13.7k
  return 0;
41
13.7k
}