• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)18 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
19   if (size > 500) {
20     return 0;
21   }
22 
23   char *new_str = (char *)malloc(size + 1);
24   if (new_str == NULL) {
25     return 0;
26   }
27   memcpy(new_str, data, size);
28   new_str[size] = '\0';
29 
30   char *str = NULL;
31   openvpn_base64_encode(data, size, &str);
32   if(str != NULL) {
33     free(str);
34   }
35 
36   uint16_t outsize = 10000;
37   char *output_buf = (char *)malloc(outsize);
38   openvpn_base64_decode(new_str, output_buf, outsize);
39   free(output_buf);
40 
41   free(new_str);
42   return 0;
43 }
44