• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 # Copyright 2020 Google Inc.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #      http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16 ################################################################################
17 */
18 
19 
20 #include "config.h"
21 #include "augeas.h"
22 #include "internal.h"
23 #include "memory.h"
24 #include "syntax.h"
25 #include "transform.h"
26 #include "errcode.h"
27 
28 
29 #include <fnmatch.h>
30 #include <argz.h>
31 #include <string.h>
32 #include <stdarg.h>
33 #include <locale.h>
34 
35 
36 
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)37 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
38 	if(size<3){
39 		return 0;
40 	}
41 
42 	char *loadpath = NULL;
43 	const char *value;
44 	const char *label;
45 	char *new_str = (char *)malloc(size+1);
46 	if (new_str == NULL){
47 		return 0;
48 	}
49 	memcpy(new_str, data, size);
50 	new_str[size] = '\0';
51 
52 	struct augeas *aug = aug_init(new_str, loadpath, AUG_NO_STDINC|AUG_NO_LOAD);
53 	aug_defvar(aug, new_str, &new_str[1]);
54 	aug_get(aug, new_str, &value);
55 	aug_label(aug, new_str, &label);
56 
57 	aug_rename(aug, new_str, &new_str[1]);
58 	aug_text_store(aug, &new_str[1], new_str, &new_str[2]);
59 	aug_print(aug, stdout, new_str);
60 	aug_setm(aug, new_str, NULL, &new_str[1]);
61 
62 	free(new_str);
63 	aug_close(aug);
64 	return 0;
65 }
66