Bug Summary

File:build-scan/../src/fuzz/fuzz-unit-file.c
Warning:line 51, column 17
Value stored to 'll' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name fuzz-unit-file.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -relaxed-aliasing -menable-no-infs -menable-no-nans -menable-unsafe-fp-math -fno-signed-zeros -mreassociate -freciprocal-math -fdenormal-fp-math=preserve-sign,preserve-sign -ffp-contract=fast -fno-rounding-math -ffast-math -ffinite-math-only -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/12.0.0 -include config.h -I fuzz-unit-file.p -I . -I .. -I src/basic -I ../src/basic -I src/shared -I ../src/shared -I src/systemd -I ../src/systemd -I src/journal -I ../src/journal -I src/journal-remote -I ../src/journal-remote -I src/nspawn -I ../src/nspawn -I src/resolve -I ../src/resolve -I src/timesync -I ../src/timesync -I ../src/time-wait-sync -I src/login -I ../src/login -I src/udev -I ../src/udev -I src/libudev -I ../src/libudev -I src/core -I ../src/core -I ../src/libsystemd/sd-bus -I ../src/libsystemd/sd-device -I ../src/libsystemd/sd-hwdb -I ../src/libsystemd/sd-id128 -I ../src/libsystemd/sd-netlink -I ../src/libsystemd/sd-network -I src/libsystemd-network -I ../src/libsystemd-network -I src/fuzz -I ../src/fuzz -I /usr/include/libmount -I /usr/include/blkid -D _FILE_OFFSET_BITS=64 -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/12.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wwrite-strings -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unused-result -Wno-format-signedness -Wno-error=nonnull -std=gnu99 -fconst-strings -fdebug-compilation-dir /home/mrc0mmand/repos/@redhat-plumbers/systemd-rhel8/build-scan -ferror-limit 19 -fvisibility hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcolor-diagnostics -analyzer-output=html -faddrsig -o /tmp/scan-build-2021-07-16-221226-1465241-1 -x c ../src/fuzz/fuzz-unit-file.c
1/* SPDX-License-Identifier: LGPL-2.1+ */
2
3#include "conf-parser.h"
4#include "fd-util.h"
5#include "fileio.h"
6#include "fuzz.h"
7#include "install.h"
8#include "load-fragment.h"
9#include "string-util.h"
10#include "unit.h"
11#include "utf8.h"
12
13int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
14 _cleanup_free___attribute__((cleanup(freep))) char *out = NULL((void*)0); /* out should be freed after g */
15 size_t out_size;
16 _cleanup_fclose___attribute__((cleanup(fclosep))) FILE *f = NULL((void*)0), *g = NULL((void*)0);
17 _cleanup_free___attribute__((cleanup(freep))) char *p = NULL((void*)0);
18 UnitType t;
19 _cleanup_(manager_freep)__attribute__((cleanup(manager_freep))) Manager *m = NULL((void*)0);
20 Unit *u;
21 const char *name;
22 long offset;
23
24 if (size == 0)
25 return 0;
26
27 f = fmemopen((char*) data, size, "re");
28 assert_se(f)do { if ((__builtin_expect(!!(!(f)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("f"), "../src/fuzz/fuzz-unit-file.c", 28
, __PRETTY_FUNCTION__); } while (0)
;
29
30 if (read_line(f, LINE_MAX2048, &p) < 0)
31 return 0;
32
33 t = unit_type_from_string(p);
34 if (t < 0)
35 return 0;
36
37 if (!unit_vtable[t]->load)
38 return 0;
39
40 offset = ftell(f);
41 assert_se(offset >= 0)do { if ((__builtin_expect(!!(!(offset >= 0)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("offset >= 0"), "../src/fuzz/fuzz-unit-file.c"
, 41, __PRETTY_FUNCTION__); } while (0)
;
42
43 for (;;) {
44 _cleanup_free___attribute__((cleanup(freep))) char *l = NULL((void*)0);
45 const char *ll;
46
47 if (read_line(f, LONG_LINE_MAX(1U*1024U*1024U), &l) <= 0)
48 break;
49
50 ll = startswith(l, UTF8_BYTE_ORDER_MARK"\xef\xbb\xbf") ?: l;
51 ll = ll + strspn(ll, WHITESPACE" \t\n\r");
Value stored to 'll' is never read
52
53 if (HAS_FEATURE_MEMORY_SANITIZER0 && startswith(ll, "ListenNetlink")) {
54 /* ListenNetlink causes a false positive in msan,
55 * let's skip this for now. */
56 log_notice("Skipping test because ListenNetlink= is present")({ int _level = (((5))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/fuzz/fuzz-unit-file.c", 56, __func__, "Skipping test because ListenNetlink= is present"
) : -abs(_e); })
;
57 return 0;
58 }
59 }
60
61 assert_se(fseek(f, offset, SEEK_SET) == 0)do { if ((__builtin_expect(!!(!(fseek(f, offset, 0) == 0)),0)
)) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("fseek(f, offset, SEEK_SET) == 0"
), "../src/fuzz/fuzz-unit-file.c", 61, __PRETTY_FUNCTION__); }
while (0)
;
62
63 /* We don't want to fill the logs with messages about parse errors.
64 * Disable most logging if not running standalone */
65 if (!getenv("SYSTEMD_LOG_LEVEL"))
66 log_set_max_level(LOG_CRIT)log_set_max_level_realm(LOG_REALM_SYSTEMD, (2));
67
68 assert_se(manager_new(UNIT_FILE_SYSTEM, MANAGER_TEST_RUN_MINIMAL, &m) >= 0)do { if ((__builtin_expect(!!(!(manager_new(UNIT_FILE_SYSTEM,
MANAGER_TEST_RUN_MINIMAL, &m) >= 0)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("manager_new(UNIT_FILE_SYSTEM, MANAGER_TEST_RUN_MINIMAL, &m) >= 0"
), "../src/fuzz/fuzz-unit-file.c", 68, __PRETTY_FUNCTION__); }
while (0)
;
69
70 name = strjoina("a.", unit_type_to_string(t))({ const char *_appendees_[] = { "a.", unit_type_to_string(t)
}; char *_d_, *_p_; size_t _len_ = 0; size_t _i_; for (_i_ =
0; _i_ < __extension__ (__builtin_choose_expr( !__builtin_types_compatible_p
(typeof(_appendees_), typeof(&*(_appendees_))), sizeof(_appendees_
)/sizeof((_appendees_)[0]), ((void)0))) && _appendees_
[_i_]; _i_++) _len_ += strlen(_appendees_[_i_]); _p_ = _d_ = __builtin_alloca
(_len_ + 1); for (_i_ = 0; _i_ < __extension__ (__builtin_choose_expr
( !__builtin_types_compatible_p(typeof(_appendees_), typeof(&
*(_appendees_))), sizeof(_appendees_)/sizeof((_appendees_)[0]
), ((void)0))) && _appendees_[_i_]; _i_++) _p_ = stpcpy
(_p_, _appendees_[_i_]); *_p_ = 0; _d_; })
;
71 assert_se(unit_new_for_name(m, unit_vtable[t]->object_size, name, &u) >= 0)do { if ((__builtin_expect(!!(!(unit_new_for_name(m, unit_vtable
[t]->object_size, name, &u) >= 0)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("unit_new_for_name(m, unit_vtable[t]->object_size, name, &u) >= 0"
), "../src/fuzz/fuzz-unit-file.c", 71, __PRETTY_FUNCTION__); }
while (0)
;
72
73 (void) config_parse(name, name, f,
74 UNIT_VTABLE(u)unit_vtable[(u)->type]->sections,
75 config_item_perf_lookup, load_fragment_gperf_lookup,
76 CONFIG_PARSE_ALLOW_INCLUDE, u);
77
78 g = open_memstream(&out, &out_size);
79 assert_se(g)do { if ((__builtin_expect(!!(!(g)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("g"), "../src/fuzz/fuzz-unit-file.c", 79
, __PRETTY_FUNCTION__); } while (0)
;
80
81 unit_dump(u, g, "");
82
83 return 0;
84}