Coverage Report

Created: 2026-07-16 07:01

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libtasn1/fuzz/asn1_decode_simple_der_fuzzer.c
Line
Count
Source
1
/*
2
 * Copyright(c) 2020 Free Software Foundation, Inc.
3
 *
4
 * This file is part of libtasn1.
5
 *
6
 * Libtasn1 is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU Lesser General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * Libtasn1 is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public License
17
 * along with libtasn1.  If not, see <https://www.gnu.org/licenses/>.
18
 *
19
 * This fuzzer is testing asn1_array2tree()'s robustness with arbitrary
20
 * input data.
21
 */
22
23
#include <config.h>
24
#include <assert.h>
25
26
#include "libtasn1.h"
27
#include "fuzzer.h"
28
29
int
30
LLVMFuzzerTestOneInput (const uint8_t *data, size_t size)
31
1.41k
{
32
1.41k
  int ret;
33
1.41k
  unsigned int ret_len;
34
1.41k
  const unsigned char *str;
35
36
1.41k
  ret =
37
1.41k
    asn1_decode_simple_der (ASN1_ETYPE_BIT_STRING, data, size, &str,
38
1.41k
          &ret_len);
39
1.41k
  if (ret == ASN1_SUCCESS)
40
0
    {
41
0
      assert (ret_len <= size);
42
0
    }
43
44
1.41k
  ret =
45
1.41k
    asn1_decode_simple_der (ASN1_ETYPE_OCTET_STRING, data, size, &str,
46
1.41k
          &ret_len);
47
1.41k
  if (ret == ASN1_SUCCESS)
48
333
    {
49
333
      assert (ret_len <= size);
50
333
    }
51
52
1.41k
  return 0;
53
1.41k
}