Coverage Report

Created: 2025-07-23 06:54

/src/fuzz_base64.c
Line
Count
Source (jump to first uncovered line)
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 <stdint.h>
13
#include <stdlib.h>
14
#include <string.h>
15
16
#include "base64.h"
17
18
203
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
19
203
  if (size > 500) {
20
13
    return 0;
21
13
  }
22
23
190
  char *new_str = (char *)malloc(size + 1);
24
190
  if (new_str == NULL) {
25
0
    return 0;
26
0
  }
27
190
  memcpy(new_str, data, size);
28
190
  new_str[size] = '\0';
29
30
190
  char *str = NULL;
31
190
  openvpn_base64_encode(data, size, &str);
32
190
  if(str != NULL) {
33
190
    free(str);
34
190
  }
35
36
190
  uint16_t outsize = 10000;
37
190
  char *output_buf = (char *)malloc(outsize);
38
190
  openvpn_base64_decode(new_str, output_buf, outsize);
39
190
  free(output_buf);
40
41
190
  free(new_str);
42
190
  return 0;
43
190
}