Coverage Report

Created: 2025-07-04 07:08

/src/fluent-bit/tests/internal/fuzzers/flb_fuzz_header.h
Line
Count
Source
1
/*  Fluent Bit
2
 *  ==========
3
 *  Copyright (C) 2019-2021 The Fluent Bit Authors
4
 *  Copyright (C) 2015-2018 Treasure Data Inc.
5
 *
6
 *  Licensed under the Apache License, Version 2.0 (the "License");
7
 *  you may not use this file except in compliance with the License.
8
 *  You may obtain a copy of the License at
9
 *
10
 *      http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 *  Unless required by applicable law or agreed to in writing, software
13
 *  distributed under the License is distributed on an "AS IS" BASIS,
14
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 *  See the License for the specific language governing permissions and
16
 *  limitations under the License.
17
 */
18
19
#include <stdint.h>
20
#include <string.h>
21
22
53.5k
#define GET_MOD_EQ(max, idx) (data[0] % max) == idx
23
57.1k
#define MOVE_INPUT(offset) data += offset; size -= offset;
24
25
19.4k
#define TIMEOUT_GUARD if (size > 32768) return 0;
26
27
char *get_null_terminated(size_t size, const uint8_t **data,
28
                          size_t *total_data_size)
29
55.1k
{
30
55.1k
  char *tmp = flb_malloc(size+1);
31
55.1k
  if (tmp == NULL) {
32
46
    tmp = malloc(size+1);
33
46
  }
34
55.1k
  memcpy(tmp, *data, size);
35
55.1k
  tmp[size] = '\0';
36
37
  /* Modify the fuzz variables */
38
55.1k
  *total_data_size -= size;
39
55.1k
  *data += size;
40
41
55.1k
  return tmp;
42
55.1k
}