Coverage Report

Created: 2026-02-26 07:12

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/opensips/parser/fuzz_csv_parser.c
Line
Count
Source
1
/* Copyright 2021 Google LLC
2
Licensed under the Apache License, Version 2.0 (the "License");
3
you may not use this file except in compliance with the License.
4
You may obtain a copy of the License at
5
      http://www.apache.org/licenses/LICENSE-2.0
6
Unless required by applicable law or agreed to in writing, software
7
distributed under the License is distributed on an "AS IS" BASIS,
8
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9
See the License for the specific language governing permissions and
10
limitations under the License.
11
*/
12
#include "../cachedb/test/test_cachedb.h"
13
#include "../lib/test/test_csv.h"
14
#include "../mem/test/test_malloc.h"
15
#include "../str.h"
16
#include "../ut.h"
17
#include "../lib/csv.h"
18
19
#include "../dprint.h"
20
#include "../globals.h"
21
#include "../lib/list.h"
22
#include "../sr_module.h"
23
#include "../sr_module_deps.h"
24
25
#include "../test/fuzz/fuzz_standalone.h"
26
27
348
int LLVMFuzzerTestOneInput(const char *data, size_t size) {
28
  // Ensure we have one byte for the "decider" variable
29
348
  if (size == 0) {
30
0
    return 0;
31
0
  }
32
348
  int decider = data[0];
33
348
  data++;
34
348
  size--;
35
36
348
  char *new_str = (char *)malloc(size + 1);
37
348
  if (new_str == NULL) {
38
0
    return 0;
39
0
  }
40
348
  memcpy(new_str, data, size);
41
348
  new_str[size] = '\0';
42
43
348
  csv_record *ret = NULL;
44
348
  if ((decider % 2) == 0) {
45
129
    ret = parse_csv_record(_str(new_str));
46
129
  }
47
219
  else {
48
219
    ret = _parse_csv_record(_str(new_str), CSV_RFC_4180);
49
219
  }
50
348
  free_csv_record(ret);
51
348
  free(new_str);
52
348
  return 0;
53
348
}