Coverage Report

Created: 2024-02-25 06:27

/src/yaml_write_handler.h
Line
Count
Source (jump to first uncovered line)
1
// Copyright 2020 Google LLC
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//      http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#ifndef YAML_WRITE_HANDLER_H_
16
#define YAML_WRITE_HANDLER_H_
17
18
typedef struct yaml_output_buffer {
19
  unsigned char *buf;
20
  size_t size;
21
} yaml_output_buffer_t;
22
23
25.1k
static int yaml_write_handler(void *data, unsigned char *buffer, size_t size) {
24
25.1k
  yaml_output_buffer_t *out = (yaml_output_buffer_t *)data;
25
26
25.1k
  out->buf = (unsigned char *)realloc(out->buf, out->size + size);
27
25.1k
  if (!out->buf) {
28
0
    out->size = 0;
29
0
    return 1;
30
0
  }
31
32
25.1k
  memcpy(out->buf + out->size, buffer, size);
33
25.1k
  out->size += size;
34
25.1k
  return 0;
35
25.1k
}
libyaml_reformatter_fuzzer.c:yaml_write_handler
Line
Count
Source
23
4.85k
static int yaml_write_handler(void *data, unsigned char *buffer, size_t size) {
24
4.85k
  yaml_output_buffer_t *out = (yaml_output_buffer_t *)data;
25
26
4.85k
  out->buf = (unsigned char *)realloc(out->buf, out->size + size);
27
4.85k
  if (!out->buf) {
28
0
    out->size = 0;
29
0
    return 1;
30
0
  }
31
32
4.85k
  memcpy(out->buf + out->size, buffer, size);
33
4.85k
  out->size += size;
34
4.85k
  return 0;
35
4.85k
}
libyaml_deconstructor_fuzzer.c:yaml_write_handler
Line
Count
Source
23
3.57k
static int yaml_write_handler(void *data, unsigned char *buffer, size_t size) {
24
3.57k
  yaml_output_buffer_t *out = (yaml_output_buffer_t *)data;
25
26
3.57k
  out->buf = (unsigned char *)realloc(out->buf, out->size + size);
27
3.57k
  if (!out->buf) {
28
0
    out->size = 0;
29
0
    return 1;
30
0
  }
31
32
3.57k
  memcpy(out->buf + out->size, buffer, size);
33
3.57k
  out->size += size;
34
3.57k
  return 0;
35
3.57k
}
Unexecuted instantiation: libyaml_emitter_fuzzer.c:yaml_write_handler
libyaml_deconstructor_alt_fuzzer.c:yaml_write_handler
Line
Count
Source
23
4.46k
static int yaml_write_handler(void *data, unsigned char *buffer, size_t size) {
24
4.46k
  yaml_output_buffer_t *out = (yaml_output_buffer_t *)data;
25
26
4.46k
  out->buf = (unsigned char *)realloc(out->buf, out->size + size);
27
4.46k
  if (!out->buf) {
28
0
    out->size = 0;
29
0
    return 1;
30
0
  }
31
32
4.46k
  memcpy(out->buf + out->size, buffer, size);
33
4.46k
  out->size += size;
34
4.46k
  return 0;
35
4.46k
}
libyaml_reformatter_alt_fuzzer.c:yaml_write_handler
Line
Count
Source
23
5.83k
static int yaml_write_handler(void *data, unsigned char *buffer, size_t size) {
24
5.83k
  yaml_output_buffer_t *out = (yaml_output_buffer_t *)data;
25
26
5.83k
  out->buf = (unsigned char *)realloc(out->buf, out->size + size);
27
5.83k
  if (!out->buf) {
28
0
    out->size = 0;
29
0
    return 1;
30
0
  }
31
32
5.83k
  memcpy(out->buf + out->size, buffer, size);
33
5.83k
  out->size += size;
34
5.83k
  return 0;
35
5.83k
}
libyaml_dumper_fuzzer.c:yaml_write_handler
Line
Count
Source
23
6.44k
static int yaml_write_handler(void *data, unsigned char *buffer, size_t size) {
24
6.44k
  yaml_output_buffer_t *out = (yaml_output_buffer_t *)data;
25
26
6.44k
  out->buf = (unsigned char *)realloc(out->buf, out->size + size);
27
6.44k
  if (!out->buf) {
28
0
    out->size = 0;
29
0
    return 1;
30
0
  }
31
32
6.44k
  memcpy(out->buf + out->size, buffer, size);
33
6.44k
  out->size += size;
34
6.44k
  return 0;
35
6.44k
}
36
37
#endif // YAML_WRITE_HANDLER_H_