File: | build-scan/../src/fuzz/fuzz-unit-file.c |
Warning: | line 51, column 17 Value stored to 'll' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
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 | |
13 | int 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 | } |