Coverage Report

Created: 2023-09-23 07:09

/src/augeas/augeas_api_fuzzer.cc
Line
Count
Source (jump to first uncovered line)
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
37
158
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
38
158
  if(size<3){
39
0
    return 0;
40
0
  }
41
  
42
158
  char *loadpath = NULL;
43
158
  const char *value;
44
158
  const char *label;
45
158
  char *new_str = (char *)malloc(size+1);
46
158
  if (new_str == NULL){
47
0
    return 0;
48
0
  }
49
158
  memcpy(new_str, data, size);
50
158
  new_str[size] = '\0';
51
  
52
158
  struct augeas *aug = aug_init(new_str, loadpath, AUG_NO_STDINC|AUG_NO_LOAD);
53
158
  aug_defvar(aug, new_str, &new_str[1]);
54
158
  aug_get(aug, new_str, &value);
55
158
  aug_label(aug, new_str, &label);
56
  
57
158
  aug_rename(aug, new_str, &new_str[1]);
58
158
  aug_text_store(aug, &new_str[1], new_str, &new_str[2]); 
59
158
  aug_print(aug, stdout, new_str);
60
158
  aug_setm(aug, new_str, NULL, &new_str[1]);  
61
  
62
158
  free(new_str);
63
158
  aug_close(aug);
64
158
  return 0;
65
158
}