Coverage Report

Created: 2026-06-30 07:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/fuzz_misc.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
13
14
#include "config.h"
15
#include "syshead.h"
16
#include "misc.h"
17
#include "buffer.h"
18
19
#include "fuzz_randomizer.h"
20
21
580
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
22
580
  fuzz_random_init(data, size);
23
24
580
  struct gc_arena gc;
25
580
  struct env_set *es;
26
580
  gc = gc_new();
27
580
  es = env_set_create(&gc);
28
29
580
  int total_to_fuzz = fuzz_randomizer_get_int(1, 9);
30
3.99k
  for (int i = 0; i <total_to_fuzz; i++) {
31
3.41k
    int type = fuzz_randomizer_get_int(0, 3);
32
3.41k
    char *tmp1 = get_random_string();
33
3.41k
    char *tmp2 = get_random_string();
34
35
3.41k
    switch (type) {
36
2.31k
    case 0:
37
2.31k
      env_set_del(es, tmp1);
38
2.31k
      break;
39
423
    case 1:
40
423
      env_set_add(es, tmp1);
41
423
      break;
42
237
    case 2:
43
237
      env_set_get(es, tmp1);
44
237
      break;
45
433
    case 3:
46
433
      if (strlen(tmp1) > 1 && strlen(tmp2) > 1) {
47
306
        setenv_str(es, tmp2, tmp1);
48
306
      }
49
433
      break;
50
0
    default:
51
0
      sanitize_control_message(tmp1, &gc);
52
3.41k
    }
53
3.41k
    free(tmp1);
54
3.41k
    free(tmp2);
55
3.41k
  }
56
57
580
  env_set_destroy(es);
58
580
  gc_free(&gc);
59
60
580
  fuzz_random_destroy();
61
580
  return 0;
62
580
}