LCOV - code coverage report
Current view: top level - fuzz - fuzz-json.c (source / functions) Hit Total Coverage
Test: systemd_full.info Lines: 0 15 0.0 %
Date: 2019-08-23 13:36:53 Functions: 0 1 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 8 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: LGPL-2.1+ */
       2                 :            : 
       3                 :            : #include "alloc-util.h"
       4                 :            : #include "fileio.h"
       5                 :            : #include "fd-util.h"
       6                 :            : #include "fuzz.h"
       7                 :            : #include "json.h"
       8                 :            : 
       9                 :          0 : int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
      10                 :          0 :         _cleanup_free_ char *out = NULL; /* out should be freed after g */
      11                 :            :         size_t out_size;
      12                 :          0 :         _cleanup_fclose_ FILE *f = NULL, *g = NULL;
      13                 :          0 :         _cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
      14                 :            : 
      15         [ #  # ]:          0 :         if (size == 0)
      16                 :          0 :                 return 0;
      17                 :            : 
      18                 :          0 :         f = fmemopen_unlocked((char*) data, size, "re");
      19         [ #  # ]:          0 :         assert_se(f);
      20                 :            : 
      21         [ #  # ]:          0 :         if (json_parse_file(f, NULL, &v, NULL, NULL) < 0)
      22                 :          0 :                 return 0;
      23                 :            : 
      24                 :          0 :         g = open_memstream_unlocked(&out, &out_size);
      25         [ #  # ]:          0 :         assert_se(g);
      26                 :            : 
      27                 :          0 :         json_variant_dump(v, 0, g, NULL);
      28                 :          0 :         json_variant_dump(v, JSON_FORMAT_PRETTY|JSON_FORMAT_COLOR|JSON_FORMAT_SOURCE, g, NULL);
      29                 :            : 
      30                 :          0 :         return 0;
      31                 :            : }

Generated by: LCOV version 1.14