LCOV - code coverage report
Current view: top level - fuzz - fuzz-bus-message.c (source / functions) Hit Total Coverage
Test: systemd_full.info Lines: 0 22 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 18 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: LGPL-2.1+ */
       2                 :            : 
       3                 :            : #include "alloc-util.h"
       4                 :            : #include "bus-dump.h"
       5                 :            : #include "bus-message.h"
       6                 :            : #include "env-util.h"
       7                 :            : #include "fd-util.h"
       8                 :            : #include "fileio.h"
       9                 :            : #include "fuzz.h"
      10                 :            : 
      11                 :          0 : int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
      12                 :          0 :         _cleanup_free_ char *out = NULL; /* out should be freed after g */
      13                 :            :         size_t out_size;
      14                 :          0 :         _cleanup_fclose_ FILE *g = NULL;
      15                 :          0 :         _cleanup_(sd_bus_unrefp) sd_bus *bus = NULL;
      16                 :          0 :         _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
      17                 :          0 :         _cleanup_free_ void *buffer = NULL;
      18                 :            :         int r;
      19                 :            : 
      20                 :            :         /* We don't want to fill the logs with messages about parse errors.
      21                 :            :          * Disable most logging if not running standalone */
      22         [ #  # ]:          0 :         if (!getenv("SYSTEMD_LOG_LEVEL"))
      23                 :          0 :                 log_set_max_level(LOG_CRIT);
      24                 :            : 
      25                 :          0 :         r = sd_bus_new(&bus);
      26         [ #  # ]:          0 :         assert_se(r >= 0);
      27                 :            : 
      28         [ #  # ]:          0 :         assert_se(buffer = memdup(data, size));
      29                 :            : 
      30                 :          0 :         r = bus_message_from_malloc(bus, buffer, size, NULL, 0, NULL, &m);
      31         [ #  # ]:          0 :         if (r == -EBADMSG)
      32                 :          0 :                 return 0;
      33         [ #  # ]:          0 :         assert_se(r >= 0);
      34                 :          0 :         TAKE_PTR(buffer);
      35                 :            : 
      36         [ #  # ]:          0 :         if (getenv_bool("SYSTEMD_FUZZ_OUTPUT") <= 0)
      37         [ #  # ]:          0 :                 assert_se(g = open_memstream_unlocked(&out, &out_size));
      38                 :            : 
      39         [ #  # ]:          0 :         bus_message_dump(m, g ?: stdout, BUS_MESSAGE_DUMP_WITH_HEADER);
      40                 :            : 
      41                 :          0 :         r = sd_bus_message_rewind(m, true);
      42         [ #  # ]:          0 :         assert_se(r >= 0);
      43                 :            : 
      44                 :          0 :         return 0;
      45                 :            : }

Generated by: LCOV version 1.14