Coverage Report

Created: 2025-07-12 06:16

/src/xz/tests/ossfuzz/fuzz_decode_stream_mt.c
Line
Count
Source (jump to first uncovered line)
1
// SPDX-License-Identifier: 0BSD
2
3
///////////////////////////////////////////////////////////////////////////////
4
//
5
/// \file       fuzz_decode_stream_mt.c
6
/// \brief      Fuzz test program for multithreaded .xz decoding
7
//
8
//  Author:     Lasse Collin
9
//
10
///////////////////////////////////////////////////////////////////////////////
11
12
#include <inttypes.h>
13
#include <stdlib.h>
14
#include <stdio.h>
15
#include "lzma.h"
16
#include "fuzz_common.h"
17
18
19
extern int
20
LLVMFuzzerTestOneInput(const uint8_t *inbuf, size_t inbuf_size)
21
12.4k
{
22
12.4k
  lzma_stream strm = LZMA_STREAM_INIT;
23
24
12.4k
  lzma_mt mt = {
25
12.4k
    .flags = LZMA_CONCATENATED | LZMA_IGNORE_CHECK,
26
12.4k
    .threads = 2,
27
12.4k
    .timeout = 0,
28
12.4k
    .memlimit_threading = MEM_LIMIT / 2,
29
12.4k
    .memlimit_stop = MEM_LIMIT,
30
12.4k
  };
31
32
12.4k
  lzma_ret ret = lzma_stream_decoder_mt(&strm, &mt);
33
34
12.4k
  if (ret != LZMA_OK) {
35
    // This should never happen unless the system has
36
    // no free memory or address space to allow the small
37
    // allocations that the initialization requires.
38
0
    fprintf(stderr, "lzma_stream_decoder_mt() failed (%d)\n", ret);
39
0
    abort();
40
0
  }
41
42
12.4k
  fuzz_code(&strm, inbuf, inbuf_size);
43
44
12.4k
  lzma_end(&strm);
45
46
12.4k
  return 0;
47
12.4k
}