LCOV - code coverage report
Current view: top level - fuzz - fuzz-journald-native-fd.c (source / functions) Hit Total Coverage
Test: systemd_full.info Lines: 0 26 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 16 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: LGPL-2.1+ */
       2                 :            : 
       3                 :            : #include "fd-util.h"
       4                 :            : #include "fs-util.h"
       5                 :            : #include "fuzz-journald.h"
       6                 :            : #include "fuzz.h"
       7                 :            : #include "journald-native.h"
       8                 :            : #include "memfd-util.h"
       9                 :            : #include "process-util.h"
      10                 :            : #include "tmpfile-util.h"
      11                 :            : 
      12                 :          0 : int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
      13                 :            :         Server s;
      14                 :          0 :         _cleanup_close_ int sealed_fd = -1, unsealed_fd = -1;
      15                 :          0 :         _cleanup_(unlink_tempfilep) char name[] = "/tmp/fuzz-journald-native-fd.XXXXXX";
      16                 :          0 :         char *label = NULL;
      17                 :          0 :         size_t label_len = 0;
      18                 :            :         struct ucred ucred;
      19                 :          0 :         struct timeval *tv = NULL;
      20                 :            : 
      21         [ #  # ]:          0 :         if (!getenv("SYSTEMD_LOG_LEVEL"))
      22                 :          0 :                 log_set_max_level(LOG_CRIT);
      23                 :            : 
      24                 :          0 :         dummy_server_init(&s, NULL, 0);
      25                 :            : 
      26                 :          0 :         sealed_fd = memfd_new(NULL);
      27         [ #  # ]:          0 :         assert_se(sealed_fd >= 0);
      28         [ #  # ]:          0 :         assert_se(write(sealed_fd, data, size) == (ssize_t) size);
      29         [ #  # ]:          0 :         assert_se(memfd_set_sealed(sealed_fd) >= 0);
      30         [ #  # ]:          0 :         assert_se(lseek(sealed_fd, 0, SEEK_SET) == 0);
      31                 :          0 :         ucred = (struct ucred) {
      32                 :          0 :                 .pid = getpid_cached(),
      33                 :          0 :                 .uid = geteuid(),
      34                 :          0 :                 .gid = getegid(),
      35                 :            :         };
      36                 :          0 :         server_process_native_file(&s, sealed_fd, &ucred, tv, label, label_len);
      37                 :            : 
      38                 :          0 :         unsealed_fd = mkostemp_safe(name);
      39         [ #  # ]:          0 :         assert_se(unsealed_fd >= 0);
      40         [ #  # ]:          0 :         assert_se(write(unsealed_fd, data, size) == (ssize_t) size);
      41         [ #  # ]:          0 :         assert_se(lseek(unsealed_fd, 0, SEEK_SET) == 0);
      42                 :          0 :         server_process_native_file(&s, unsealed_fd, &ucred, tv, label, label_len);
      43                 :            : 
      44                 :          0 :         server_done(&s);
      45                 :            : 
      46                 :          0 :         return 0;
      47                 :            : }

Generated by: LCOV version 1.14