Bug Summary

File:build-scan/../src/test/test-nss.c
Warning:line 412, column 49
Dereference of null pointer

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 test-nss.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 test-nss.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 -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/test/test-nss.c
1/* SPDX-License-Identifier: LGPL-2.1+ */
2
3#include <dlfcn.h>
4#include <stdlib.h>
5#include <net/if.h>
6
7#include "log.h"
8#include "nss-util.h"
9#include "path-util.h"
10#include "string-util.h"
11#include "alloc-util.h"
12#include "in-addr-util.h"
13#include "hexdecoct.h"
14#include "af-list.h"
15#include "stdio-util.h"
16#include "strv.h"
17#include "errno-list.h"
18#include "hostname-util.h"
19#include "local-addresses.h"
20
21static const char* nss_status_to_string(enum nss_status status, char *buf, size_t buf_len) {
22 switch (status) {
23 case NSS_STATUS_TRYAGAIN:
24 return "NSS_STATUS_TRYAGAIN";
25 case NSS_STATUS_UNAVAIL:
26 return "NSS_STATUS_UNAVAIL";
27 case NSS_STATUS_NOTFOUND:
28 return "NSS_STATUS_NOTFOUND";
29 case NSS_STATUS_SUCCESS:
30 return "NSS_STATUS_SUCCESS";
31 case NSS_STATUS_RETURN:
32 return "NSS_STATUS_RETURN";
33 default:
34 snprintf(buf, buf_len, "%i", status);
35 return buf;
36 }
37};
38
39static const char* af_to_string(int family, char *buf, size_t buf_len) {
40 const char *name;
41
42 if (family == AF_UNSPEC0)
43 return "*";
44
45 name = af_to_name(family);
46 if (name)
47 return name;
48
49 snprintf(buf, buf_len, "%i", family);
50 return buf;
51}
52
53static void* open_handle(const char* dir, const char* module, int flags) {
54 const char *path;
55 void *handle;
56
57 if (dir) {
58 path = strjoina(dir, "/libnss_", module, ".so.2")({ const char *_appendees_[] = { dir, "/libnss_", module, ".so.2"
}; 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_; })
;
59 if (access(path, F_OK0) < 0)
60 path = strjoina(dir, "/.libs/libnss_", module, ".so.2")({ const char *_appendees_[] = { dir, "/.libs/libnss_", module
, ".so.2" }; 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_; })
;
61 } else
62 path = strjoina("libnss_", module, ".so.2")({ const char *_appendees_[] = { "libnss_", module, ".so.2" }
; 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_; })
;
63
64 handle = dlopen(path, flags);
65 if (!handle)
66 log_error("Failed to load module %s: %s", module, dlerror())({ int _level = (((3))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 66, __func__, "Failed to load module %s: %s"
, module, dlerror()) : -abs(_e); })
;
67 return handle;
68}
69
70static int print_gaih_addrtuples(const struct gaih_addrtuple *tuples) {
71 const struct gaih_addrtuple *it;
72 int n = 0;
73
74 for (it = tuples; it; it = it->next) {
75 _cleanup_free___attribute__((cleanup(freep))) char *a = NULL((void*)0);
76 union in_addr_union u;
77 int r;
78 char family_name[DECIMAL_STR_MAX(int)(2+(sizeof(int) <= 1 ? 3 : sizeof(int) <= 2 ? 5 : sizeof
(int) <= 4 ? 10 : sizeof(int) <= 8 ? 20 : sizeof(int[-2
*(sizeof(int) > 8)])))
];
79 char ifname[IF_NAMESIZE16];
80
81 memcpy(&u, it->addr, 16);
82 r = in_addr_to_string(it->family, &u, &a);
83 assert_se(IN_SET(r, 0, -EAFNOSUPPORT))do { if ((__builtin_expect(!!(!(({ _Bool _found = 0; static __attribute__
((unused)) char _static_assert__macros_need_to_be_extended[20
- sizeof((int[]){0, -97})/sizeof(int)]; switch(r) { case 0: case
-97: _found = 1; break; default: break; } _found; }))),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("IN_SET(r, 0, -EAFNOSUPPORT)"), "../src/test/test-nss.c"
, 83, __PRETTY_FUNCTION__); } while (0)
;
84 if (r == -EAFNOSUPPORT97)
85 assert_se(a = hexmem(it->addr, 16))do { if ((__builtin_expect(!!(!(a = hexmem(it->addr, 16)))
,0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("a = hexmem(it->addr, 16)"
), "../src/test/test-nss.c", 85, __PRETTY_FUNCTION__); } while
(0)
;
86
87 if (it->scopeid == 0)
88 goto numerical_index;
89
90 if (if_indextoname(it->scopeid, ifname) == NULL((void*)0)) {
91 log_warning_errno(errno, "if_indextoname(%d) failed: %m", it->scopeid)({ int _level = ((4)), _e = (((*__errno_location ()))), _realm
= (LOG_REALM_SYSTEMD); (log_get_max_level_realm(_realm) >=
((_level) & 0x07)) ? log_internal_realm(((_realm) <<
10 | (_level)), _e, "../src/test/test-nss.c", 91, __func__, "if_indextoname(%d) failed: %m"
, it->scopeid) : -abs(_e); })
;
92 numerical_index:
93 xsprintf(ifname, "%i", it->scopeid)do { if ((__builtin_expect(!!(!(((size_t) snprintf(ifname, __extension__
(__builtin_choose_expr( !__builtin_types_compatible_p(typeof
(ifname), typeof(&*(ifname))), sizeof(ifname)/sizeof((ifname
)[0]), ((void)0))), "%i", it->scopeid) < (__extension__
(__builtin_choose_expr( !__builtin_types_compatible_p(typeof
(ifname), typeof(&*(ifname))), sizeof(ifname)/sizeof((ifname
)[0]), ((void)0))))))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("xsprintf: " "ifname" "[] must be big enough"), "../src/test/test-nss.c"
, 93, __PRETTY_FUNCTION__); } while (0)
;
94 };
95
96 log_info(" \"%s\" %s %s %%%s",({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 100, __func__, " \"%s\" %s %s %%%s"
, it->name, af_to_string(it->family, family_name, sizeof
family_name), a, ifname) : -abs(_e); })
97 it->name,({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 100, __func__, " \"%s\" %s %s %%%s"
, it->name, af_to_string(it->family, family_name, sizeof
family_name), a, ifname) : -abs(_e); })
98 af_to_string(it->family, family_name, sizeof family_name),({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 100, __func__, " \"%s\" %s %s %%%s"
, it->name, af_to_string(it->family, family_name, sizeof
family_name), a, ifname) : -abs(_e); })
99 a,({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 100, __func__, " \"%s\" %s %s %%%s"
, it->name, af_to_string(it->family, family_name, sizeof
family_name), a, ifname) : -abs(_e); })
100 ifname)({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 100, __func__, " \"%s\" %s %s %%%s"
, it->name, af_to_string(it->family, family_name, sizeof
family_name), a, ifname) : -abs(_e); })
;
101 n ++;
102 }
103 return n;
104}
105
106static void print_struct_hostent(struct hostent *host, const char *canon) {
107 char **s;
108
109 log_info(" \"%s\"", host->h_name)({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 109, __func__, " \"%s\"", host
->h_name) : -abs(_e); })
;
110 STRV_FOREACH(s, host->h_aliases)for ((s) = (host->h_aliases); (s) && *(s); (s)++)
111 log_info(" alias \"%s\"", *s)({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 111, __func__, " alias \"%s\""
, *s) : -abs(_e); })
;
112 STRV_FOREACH(s, host->h_addr_list)for ((s) = (host->h_addr_list); (s) && *(s); (s)++
)
{
113 union in_addr_union u;
114 _cleanup_free___attribute__((cleanup(freep))) char *a = NULL((void*)0);
115 char family_name[DECIMAL_STR_MAX(int)(2+(sizeof(int) <= 1 ? 3 : sizeof(int) <= 2 ? 5 : sizeof
(int) <= 4 ? 10 : sizeof(int) <= 8 ? 20 : sizeof(int[-2
*(sizeof(int) > 8)])))
];
116 int r;
117
118 assert_se((unsigned) host->h_length == FAMILY_ADDRESS_SIZE(host->h_addrtype))do { if ((__builtin_expect(!!(!((unsigned) host->h_length ==
FAMILY_ADDRESS_SIZE(host->h_addrtype))),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("(unsigned) host->h_length == FAMILY_ADDRESS_SIZE(host->h_addrtype)"
), "../src/test/test-nss.c", 118, __PRETTY_FUNCTION__); } while
(0)
;
119 memcpy(&u, *s, host->h_length);
120 r = in_addr_to_string(host->h_addrtype, &u, &a);
121 assert_se(r == 0)do { if ((__builtin_expect(!!(!(r == 0)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("r == 0"), "../src/test/test-nss.c", 121
, __PRETTY_FUNCTION__); } while (0)
;
122 log_info(" %s %s",({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 124, __func__, " %s %s", af_to_string
(host->h_addrtype, family_name, sizeof family_name), a) : -
abs(_e); })
123 af_to_string(host->h_addrtype, family_name, sizeof family_name),({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 124, __func__, " %s %s", af_to_string
(host->h_addrtype, family_name, sizeof family_name), a) : -
abs(_e); })
124 a)({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 124, __func__, " %s %s", af_to_string
(host->h_addrtype, family_name, sizeof family_name), a) : -
abs(_e); })
;
125 }
126 if (canon)
127 log_info(" canonical: \"%s\"", canon)({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 127, __func__, " canonical: \"%s\""
, canon) : -abs(_e); })
;
128}
129
130static void test_gethostbyname4_r(void *handle, const char *module, const char *name) {
131 const char *fname;
132 _nss_gethostbyname4_r_t f;
133 char buffer[2000];
134 struct gaih_addrtuple *pat = NULL((void*)0);
135 int errno1 = 999, errno2 = 999; /* nss-dns doesn't set those */
136 int32_t ttl = INT32_MAX(2147483647); /* nss-dns wants to return the lowest ttl,
137 and will access this variable through *ttlp,
138 so we need to set it to something.
139 I'm not sure if this is a bug in nss-dns
140 or not. */
141 enum nss_status status;
142 char pretty_status[DECIMAL_STR_MAX(enum nss_status)(2+(sizeof(enum nss_status) <= 1 ? 3 : sizeof(enum nss_status
) <= 2 ? 5 : sizeof(enum nss_status) <= 4 ? 10 : sizeof
(enum nss_status) <= 8 ? 20 : sizeof(int[-2*(sizeof(enum nss_status
) > 8)])))
];
143 int n;
144
145 fname = strjoina("_nss_", module, "_gethostbyname4_r")({ const char *_appendees_[] = { "_nss_", module, "_gethostbyname4_r"
}; 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_; })
;
146 f = dlsym(handle, fname);
147 log_debug("dlsym(0x%p, %s) → 0x%p", handle, fname, f)({ int _level = (((7))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 147, __func__, "dlsym(0x%p, %s) → 0x%p"
, handle, fname, f) : -abs(_e); })
;
148 assert_se(f)do { if ((__builtin_expect(!!(!(f)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("f"), "../src/test/test-nss.c", 148, __PRETTY_FUNCTION__
); } while (0)
;
149
150 status = f(name, &pat, buffer, sizeof buffer, &errno1, &errno2, &ttl);
151 if (status == NSS_STATUS_SUCCESS) {
152 log_info("%s(\"%s\") → status=%s%-20spat=buffer+0x%tx errno=%d/%s h_errno=%d/%s ttl=%"PRIi32,({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 158, __func__, "%s(\"%s\") → status=%s%-20spat=buffer+0x%tx errno=%d/%s h_errno=%d/%s ttl=%"
"i", fname, name, nss_status_to_string(status, pretty_status,
sizeof pretty_status), "\n", pat ? (char*) pat - buffer : 0,
errno1, errno_to_name(errno1) ?: "---", errno2, hstrerror(errno2
), ttl) : -abs(_e); })
153 fname, name,({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 158, __func__, "%s(\"%s\") → status=%s%-20spat=buffer+0x%tx errno=%d/%s h_errno=%d/%s ttl=%"
"i", fname, name, nss_status_to_string(status, pretty_status,
sizeof pretty_status), "\n", pat ? (char*) pat - buffer : 0,
errno1, errno_to_name(errno1) ?: "---", errno2, hstrerror(errno2
), ttl) : -abs(_e); })
154 nss_status_to_string(status, pretty_status, sizeof pretty_status), "\n",({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 158, __func__, "%s(\"%s\") → status=%s%-20spat=buffer+0x%tx errno=%d/%s h_errno=%d/%s ttl=%"
"i", fname, name, nss_status_to_string(status, pretty_status,
sizeof pretty_status), "\n", pat ? (char*) pat - buffer : 0,
errno1, errno_to_name(errno1) ?: "---", errno2, hstrerror(errno2
), ttl) : -abs(_e); })
155 pat ? (char*) pat - buffer : 0,({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 158, __func__, "%s(\"%s\") → status=%s%-20spat=buffer+0x%tx errno=%d/%s h_errno=%d/%s ttl=%"
"i", fname, name, nss_status_to_string(status, pretty_status,
sizeof pretty_status), "\n", pat ? (char*) pat - buffer : 0,
errno1, errno_to_name(errno1) ?: "---", errno2, hstrerror(errno2
), ttl) : -abs(_e); })
156 errno1, errno_to_name(errno1) ?: "---",({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 158, __func__, "%s(\"%s\") → status=%s%-20spat=buffer+0x%tx errno=%d/%s h_errno=%d/%s ttl=%"
"i", fname, name, nss_status_to_string(status, pretty_status,
sizeof pretty_status), "\n", pat ? (char*) pat - buffer : 0,
errno1, errno_to_name(errno1) ?: "---", errno2, hstrerror(errno2
), ttl) : -abs(_e); })
157 errno2, hstrerror(errno2),({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 158, __func__, "%s(\"%s\") → status=%s%-20spat=buffer+0x%tx errno=%d/%s h_errno=%d/%s ttl=%"
"i", fname, name, nss_status_to_string(status, pretty_status,
sizeof pretty_status), "\n", pat ? (char*) pat - buffer : 0,
errno1, errno_to_name(errno1) ?: "---", errno2, hstrerror(errno2
), ttl) : -abs(_e); })
158 ttl)({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 158, __func__, "%s(\"%s\") → status=%s%-20spat=buffer+0x%tx errno=%d/%s h_errno=%d/%s ttl=%"
"i", fname, name, nss_status_to_string(status, pretty_status,
sizeof pretty_status), "\n", pat ? (char*) pat - buffer : 0,
errno1, errno_to_name(errno1) ?: "---", errno2, hstrerror(errno2
), ttl) : -abs(_e); })
;
159 n = print_gaih_addrtuples(pat);
160 } else {
161 log_info("%s(\"%s\") → status=%s%-20spat=0x%p errno=%d/%s h_errno=%d/%s",({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 166, __func__, "%s(\"%s\") → status=%s%-20spat=0x%p errno=%d/%s h_errno=%d/%s"
, fname, name, nss_status_to_string(status, pretty_status, sizeof
pretty_status), "\n", pat, errno1, errno_to_name(errno1) ?: "---"
, errno2, hstrerror(errno2)) : -abs(_e); })
162 fname, name,({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 166, __func__, "%s(\"%s\") → status=%s%-20spat=0x%p errno=%d/%s h_errno=%d/%s"
, fname, name, nss_status_to_string(status, pretty_status, sizeof
pretty_status), "\n", pat, errno1, errno_to_name(errno1) ?: "---"
, errno2, hstrerror(errno2)) : -abs(_e); })
163 nss_status_to_string(status, pretty_status, sizeof pretty_status), "\n",({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 166, __func__, "%s(\"%s\") → status=%s%-20spat=0x%p errno=%d/%s h_errno=%d/%s"
, fname, name, nss_status_to_string(status, pretty_status, sizeof
pretty_status), "\n", pat, errno1, errno_to_name(errno1) ?: "---"
, errno2, hstrerror(errno2)) : -abs(_e); })
164 pat,({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 166, __func__, "%s(\"%s\") → status=%s%-20spat=0x%p errno=%d/%s h_errno=%d/%s"
, fname, name, nss_status_to_string(status, pretty_status, sizeof
pretty_status), "\n", pat, errno1, errno_to_name(errno1) ?: "---"
, errno2, hstrerror(errno2)) : -abs(_e); })
165 errno1, errno_to_name(errno1) ?: "---",({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 166, __func__, "%s(\"%s\") → status=%s%-20spat=0x%p errno=%d/%s h_errno=%d/%s"
, fname, name, nss_status_to_string(status, pretty_status, sizeof
pretty_status), "\n", pat, errno1, errno_to_name(errno1) ?: "---"
, errno2, hstrerror(errno2)) : -abs(_e); })
166 errno2, hstrerror(errno2))({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 166, __func__, "%s(\"%s\") → status=%s%-20spat=0x%p errno=%d/%s h_errno=%d/%s"
, fname, name, nss_status_to_string(status, pretty_status, sizeof
pretty_status), "\n", pat, errno1, errno_to_name(errno1) ?: "---"
, errno2, hstrerror(errno2)) : -abs(_e); })
;
167 n = 0;
168 }
169
170 if (STR_IN_SET(module, "resolve", "mymachines")(!!strv_find((((char**) ((const char*[]) { "resolve", "mymachines"
, ((void*)0) }))), (module)))
&& status == NSS_STATUS_UNAVAIL)
171 return;
172
173 if (STR_IN_SET(module, "myhostname", "resolve")(!!strv_find((((char**) ((const char*[]) { "myhostname", "resolve"
, ((void*)0) }))), (module)))
&& streq(name, "localhost")(strcmp((name),("localhost")) == 0)) {
174 assert_se(status == NSS_STATUS_SUCCESS)do { if ((__builtin_expect(!!(!(status == NSS_STATUS_SUCCESS)
),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("status == NSS_STATUS_SUCCESS"
), "../src/test/test-nss.c", 174, __PRETTY_FUNCTION__); } while
(0)
;
175 assert_se(n == 2)do { if ((__builtin_expect(!!(!(n == 2)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("n == 2"), "../src/test/test-nss.c", 175
, __PRETTY_FUNCTION__); } while (0)
;
176 }
177}
178
179static void test_gethostbyname3_r(void *handle, const char *module, const char *name, int af) {
180 const char *fname;
181 _nss_gethostbyname3_r_t f;
182 char buffer[2000];
183 int errno1 = 999, errno2 = 999; /* nss-dns doesn't set those */
184 int32_t ttl = INT32_MAX(2147483647); /* nss-dns wants to return the lowest ttl,
185 and will access this variable through *ttlp,
186 so we need to set it to something.
187 I'm not sure if this is a bug in nss-dns
188 or not. */
189 enum nss_status status;
190 char pretty_status[DECIMAL_STR_MAX(enum nss_status)(2+(sizeof(enum nss_status) <= 1 ? 3 : sizeof(enum nss_status
) <= 2 ? 5 : sizeof(enum nss_status) <= 4 ? 10 : sizeof
(enum nss_status) <= 8 ? 20 : sizeof(int[-2*(sizeof(enum nss_status
) > 8)])))
];
191 struct hostent host;
192 char *canon;
193 char family_name[DECIMAL_STR_MAX(int)(2+(sizeof(int) <= 1 ? 3 : sizeof(int) <= 2 ? 5 : sizeof
(int) <= 4 ? 10 : sizeof(int) <= 8 ? 20 : sizeof(int[-2
*(sizeof(int) > 8)])))
];
194
195 fname = strjoina("_nss_", module, "_gethostbyname3_r")({ const char *_appendees_[] = { "_nss_", module, "_gethostbyname3_r"
}; 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_; })
;
196 f = dlsym(handle, fname);
197 log_debug("dlsym(0x%p, %s) → 0x%p", handle, fname, f)({ int _level = (((7))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 197, __func__, "dlsym(0x%p, %s) → 0x%p"
, handle, fname, f) : -abs(_e); })
;
198 assert_se(f)do { if ((__builtin_expect(!!(!(f)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("f"), "../src/test/test-nss.c", 198, __PRETTY_FUNCTION__
); } while (0)
;
199
200 status = f(name, af, &host, buffer, sizeof buffer, &errno1, &errno2, &ttl, &canon);
201 log_info("%s(\"%s\", %s) → status=%s%-20serrno=%d/%s h_errno=%d/%s ttl=%"PRIi32,({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 206, __func__, "%s(\"%s\", %s) → status=%s%-20serrno=%d/%s h_errno=%d/%s ttl=%"
"i", fname, name, af_to_string(af, family_name, sizeof family_name
), nss_status_to_string(status, pretty_status, sizeof pretty_status
), "\n", errno1, errno_to_name(errno1) ?: "---", errno2, hstrerror
(errno2), ttl) : -abs(_e); })
202 fname, name, af_to_string(af, family_name, sizeof family_name),({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 206, __func__, "%s(\"%s\", %s) → status=%s%-20serrno=%d/%s h_errno=%d/%s ttl=%"
"i", fname, name, af_to_string(af, family_name, sizeof family_name
), nss_status_to_string(status, pretty_status, sizeof pretty_status
), "\n", errno1, errno_to_name(errno1) ?: "---", errno2, hstrerror
(errno2), ttl) : -abs(_e); })
203 nss_status_to_string(status, pretty_status, sizeof pretty_status), "\n",({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 206, __func__, "%s(\"%s\", %s) → status=%s%-20serrno=%d/%s h_errno=%d/%s ttl=%"
"i", fname, name, af_to_string(af, family_name, sizeof family_name
), nss_status_to_string(status, pretty_status, sizeof pretty_status
), "\n", errno1, errno_to_name(errno1) ?: "---", errno2, hstrerror
(errno2), ttl) : -abs(_e); })
204 errno1, errno_to_name(errno1) ?: "---",({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 206, __func__, "%s(\"%s\", %s) → status=%s%-20serrno=%d/%s h_errno=%d/%s ttl=%"
"i", fname, name, af_to_string(af, family_name, sizeof family_name
), nss_status_to_string(status, pretty_status, sizeof pretty_status
), "\n", errno1, errno_to_name(errno1) ?: "---", errno2, hstrerror
(errno2), ttl) : -abs(_e); })
205 errno2, hstrerror(errno2),({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 206, __func__, "%s(\"%s\", %s) → status=%s%-20serrno=%d/%s h_errno=%d/%s ttl=%"
"i", fname, name, af_to_string(af, family_name, sizeof family_name
), nss_status_to_string(status, pretty_status, sizeof pretty_status
), "\n", errno1, errno_to_name(errno1) ?: "---", errno2, hstrerror
(errno2), ttl) : -abs(_e); })
206 ttl)({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 206, __func__, "%s(\"%s\", %s) → status=%s%-20serrno=%d/%s h_errno=%d/%s ttl=%"
"i", fname, name, af_to_string(af, family_name, sizeof family_name
), nss_status_to_string(status, pretty_status, sizeof pretty_status
), "\n", errno1, errno_to_name(errno1) ?: "---", errno2, hstrerror
(errno2), ttl) : -abs(_e); })
;
207 if (status == NSS_STATUS_SUCCESS)
208 print_struct_hostent(&host, canon);
209}
210
211static void test_gethostbyname2_r(void *handle, const char *module, const char *name, int af) {
212 const char *fname;
213 _nss_gethostbyname2_r_t f;
214 char buffer[2000];
215 int errno1 = 999, errno2 = 999; /* nss-dns doesn't set those */
216 enum nss_status status;
217 char pretty_status[DECIMAL_STR_MAX(enum nss_status)(2+(sizeof(enum nss_status) <= 1 ? 3 : sizeof(enum nss_status
) <= 2 ? 5 : sizeof(enum nss_status) <= 4 ? 10 : sizeof
(enum nss_status) <= 8 ? 20 : sizeof(int[-2*(sizeof(enum nss_status
) > 8)])))
];
218 struct hostent host;
219 char family_name[DECIMAL_STR_MAX(int)(2+(sizeof(int) <= 1 ? 3 : sizeof(int) <= 2 ? 5 : sizeof
(int) <= 4 ? 10 : sizeof(int) <= 8 ? 20 : sizeof(int[-2
*(sizeof(int) > 8)])))
];
220
221 fname = strjoina("_nss_", module, "_gethostbyname2_r")({ const char *_appendees_[] = { "_nss_", module, "_gethostbyname2_r"
}; 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_; })
;
222 f = dlsym(handle, fname);
223 log_debug("dlsym(0x%p, %s) → 0x%p", handle, fname, f)({ int _level = (((7))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 223, __func__, "dlsym(0x%p, %s) → 0x%p"
, handle, fname, f) : -abs(_e); })
;
224 assert_se(f)do { if ((__builtin_expect(!!(!(f)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("f"), "../src/test/test-nss.c", 224, __PRETTY_FUNCTION__
); } while (0)
;
225
226 status = f(name, af, &host, buffer, sizeof buffer, &errno1, &errno2);
227 log_info("%s(\"%s\", %s) → status=%s%-20serrno=%d/%s h_errno=%d/%s",({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 231, __func__, "%s(\"%s\", %s) → status=%s%-20serrno=%d/%s h_errno=%d/%s"
, fname, name, af_to_string(af, family_name, sizeof family_name
), nss_status_to_string(status, pretty_status, sizeof pretty_status
), "\n", errno1, errno_to_name(errno1) ?: "---", errno2, hstrerror
(errno2)) : -abs(_e); })
228 fname, name, af_to_string(af, family_name, sizeof family_name),({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 231, __func__, "%s(\"%s\", %s) → status=%s%-20serrno=%d/%s h_errno=%d/%s"
, fname, name, af_to_string(af, family_name, sizeof family_name
), nss_status_to_string(status, pretty_status, sizeof pretty_status
), "\n", errno1, errno_to_name(errno1) ?: "---", errno2, hstrerror
(errno2)) : -abs(_e); })
229 nss_status_to_string(status, pretty_status, sizeof pretty_status), "\n",({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 231, __func__, "%s(\"%s\", %s) → status=%s%-20serrno=%d/%s h_errno=%d/%s"
, fname, name, af_to_string(af, family_name, sizeof family_name
), nss_status_to_string(status, pretty_status, sizeof pretty_status
), "\n", errno1, errno_to_name(errno1) ?: "---", errno2, hstrerror
(errno2)) : -abs(_e); })
230 errno1, errno_to_name(errno1) ?: "---",({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 231, __func__, "%s(\"%s\", %s) → status=%s%-20serrno=%d/%s h_errno=%d/%s"
, fname, name, af_to_string(af, family_name, sizeof family_name
), nss_status_to_string(status, pretty_status, sizeof pretty_status
), "\n", errno1, errno_to_name(errno1) ?: "---", errno2, hstrerror
(errno2)) : -abs(_e); })
231 errno2, hstrerror(errno2))({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 231, __func__, "%s(\"%s\", %s) → status=%s%-20serrno=%d/%s h_errno=%d/%s"
, fname, name, af_to_string(af, family_name, sizeof family_name
), nss_status_to_string(status, pretty_status, sizeof pretty_status
), "\n", errno1, errno_to_name(errno1) ?: "---", errno2, hstrerror
(errno2)) : -abs(_e); })
;
232 if (status == NSS_STATUS_SUCCESS)
233 print_struct_hostent(&host, NULL((void*)0));
234}
235
236static void test_gethostbyname_r(void *handle, const char *module, const char *name) {
237 const char *fname;
238 _nss_gethostbyname_r_t f;
239 char buffer[2000];
240 int errno1 = 999, errno2 = 999; /* nss-dns doesn't set those */
241 enum nss_status status;
242 char pretty_status[DECIMAL_STR_MAX(enum nss_status)(2+(sizeof(enum nss_status) <= 1 ? 3 : sizeof(enum nss_status
) <= 2 ? 5 : sizeof(enum nss_status) <= 4 ? 10 : sizeof
(enum nss_status) <= 8 ? 20 : sizeof(int[-2*(sizeof(enum nss_status
) > 8)])))
];
243 struct hostent host;
244
245 fname = strjoina("_nss_", module, "_gethostbyname_r")({ const char *_appendees_[] = { "_nss_", module, "_gethostbyname_r"
}; 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_; })
;
246 f = dlsym(handle, fname);
247 log_debug("dlsym(0x%p, %s) → 0x%p", handle, fname, f)({ int _level = (((7))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 247, __func__, "dlsym(0x%p, %s) → 0x%p"
, handle, fname, f) : -abs(_e); })
;
248 assert_se(f)do { if ((__builtin_expect(!!(!(f)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("f"), "../src/test/test-nss.c", 248, __PRETTY_FUNCTION__
); } while (0)
;
249
250 status = f(name, &host, buffer, sizeof buffer, &errno1, &errno2);
251 log_info("%s(\"%s\") → status=%s%-20serrno=%d/%s h_errno=%d/%s",({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 255, __func__, "%s(\"%s\") → status=%s%-20serrno=%d/%s h_errno=%d/%s"
, fname, name, nss_status_to_string(status, pretty_status, sizeof
pretty_status), "\n", errno1, errno_to_name(errno1) ?: "---"
, errno2, hstrerror(errno2)) : -abs(_e); })
252 fname, name,({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 255, __func__, "%s(\"%s\") → status=%s%-20serrno=%d/%s h_errno=%d/%s"
, fname, name, nss_status_to_string(status, pretty_status, sizeof
pretty_status), "\n", errno1, errno_to_name(errno1) ?: "---"
, errno2, hstrerror(errno2)) : -abs(_e); })
253 nss_status_to_string(status, pretty_status, sizeof pretty_status), "\n",({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 255, __func__, "%s(\"%s\") → status=%s%-20serrno=%d/%s h_errno=%d/%s"
, fname, name, nss_status_to_string(status, pretty_status, sizeof
pretty_status), "\n", errno1, errno_to_name(errno1) ?: "---"
, errno2, hstrerror(errno2)) : -abs(_e); })
254 errno1, errno_to_name(errno1) ?: "---",({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 255, __func__, "%s(\"%s\") → status=%s%-20serrno=%d/%s h_errno=%d/%s"
, fname, name, nss_status_to_string(status, pretty_status, sizeof
pretty_status), "\n", errno1, errno_to_name(errno1) ?: "---"
, errno2, hstrerror(errno2)) : -abs(_e); })
255 errno2, hstrerror(errno2))({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 255, __func__, "%s(\"%s\") → status=%s%-20serrno=%d/%s h_errno=%d/%s"
, fname, name, nss_status_to_string(status, pretty_status, sizeof
pretty_status), "\n", errno1, errno_to_name(errno1) ?: "---"
, errno2, hstrerror(errno2)) : -abs(_e); })
;
256 if (status == NSS_STATUS_SUCCESS)
257 print_struct_hostent(&host, NULL((void*)0));
258}
259
260static void test_gethostbyaddr2_r(void *handle,
261 const char *module,
262 const void* addr, socklen_t len,
263 int af) {
264
265 const char *fname;
266 _nss_gethostbyaddr2_r_t f;
267 char buffer[2000];
268 int errno1 = 999, errno2 = 999; /* nss-dns doesn't set those */
269 enum nss_status status;
270 char pretty_status[DECIMAL_STR_MAX(enum nss_status)(2+(sizeof(enum nss_status) <= 1 ? 3 : sizeof(enum nss_status
) <= 2 ? 5 : sizeof(enum nss_status) <= 4 ? 10 : sizeof
(enum nss_status) <= 8 ? 20 : sizeof(int[-2*(sizeof(enum nss_status
) > 8)])))
];
271 struct hostent host;
272 int32_t ttl = INT32_MAX(2147483647);
273 _cleanup_free___attribute__((cleanup(freep))) char *addr_pretty = NULL((void*)0);
274
275 fname = strjoina("_nss_", module, "_gethostbyaddr2_r")({ const char *_appendees_[] = { "_nss_", module, "_gethostbyaddr2_r"
}; 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_; })
;
276 f = dlsym(handle, fname);
277
278 log_full_errno(f ? LOG_DEBUG : LOG_INFO, errno,({ int _level = ((f ? 7 : 6)), _e = (((*__errno_location ()))
), _realm = (LOG_REALM_SYSTEMD); (log_get_max_level_realm(_realm
) >= ((_level) & 0x07)) ? log_internal_realm(((_realm)
<< 10 | (_level)), _e, "../src/test/test-nss.c", 279, __func__
, "dlsym(0x%p, %s) → 0x%p: %m", handle, fname, f) : -abs(_e
); })
279 "dlsym(0x%p, %s) → 0x%p: %m", handle, fname, f)({ int _level = ((f ? 7 : 6)), _e = (((*__errno_location ()))
), _realm = (LOG_REALM_SYSTEMD); (log_get_max_level_realm(_realm
) >= ((_level) & 0x07)) ? log_internal_realm(((_realm)
<< 10 | (_level)), _e, "../src/test/test-nss.c", 279, __func__
, "dlsym(0x%p, %s) → 0x%p: %m", handle, fname, f) : -abs(_e
); })
;
280 if (!f)
281 return;
282
283 assert_se(in_addr_to_string(af, addr, &addr_pretty) >= 0)do { if ((__builtin_expect(!!(!(in_addr_to_string(af, addr, &
addr_pretty) >= 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("in_addr_to_string(af, addr, &addr_pretty) >= 0"), "../src/test/test-nss.c"
, 283, __PRETTY_FUNCTION__); } while (0)
;
284
285 status = f(addr, len, af, &host, buffer, sizeof buffer, &errno1, &errno2, &ttl);
286 log_info("%s(\"%s\") → status=%s%-20serrno=%d/%s h_errno=%d/%s ttl=%"PRIi32,({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 291, __func__, "%s(\"%s\") → status=%s%-20serrno=%d/%s h_errno=%d/%s ttl=%"
"i", fname, addr_pretty, nss_status_to_string(status, pretty_status
, sizeof pretty_status), "\n", errno1, errno_to_name(errno1) ?
: "---", errno2, hstrerror(errno2), ttl) : -abs(_e); })
287 fname, addr_pretty,({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 291, __func__, "%s(\"%s\") → status=%s%-20serrno=%d/%s h_errno=%d/%s ttl=%"
"i", fname, addr_pretty, nss_status_to_string(status, pretty_status
, sizeof pretty_status), "\n", errno1, errno_to_name(errno1) ?
: "---", errno2, hstrerror(errno2), ttl) : -abs(_e); })
288 nss_status_to_string(status, pretty_status, sizeof pretty_status), "\n",({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 291, __func__, "%s(\"%s\") → status=%s%-20serrno=%d/%s h_errno=%d/%s ttl=%"
"i", fname, addr_pretty, nss_status_to_string(status, pretty_status
, sizeof pretty_status), "\n", errno1, errno_to_name(errno1) ?
: "---", errno2, hstrerror(errno2), ttl) : -abs(_e); })
289 errno1, errno_to_name(errno1) ?: "---",({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 291, __func__, "%s(\"%s\") → status=%s%-20serrno=%d/%s h_errno=%d/%s ttl=%"
"i", fname, addr_pretty, nss_status_to_string(status, pretty_status
, sizeof pretty_status), "\n", errno1, errno_to_name(errno1) ?
: "---", errno2, hstrerror(errno2), ttl) : -abs(_e); })
290 errno2, hstrerror(errno2),({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 291, __func__, "%s(\"%s\") → status=%s%-20serrno=%d/%s h_errno=%d/%s ttl=%"
"i", fname, addr_pretty, nss_status_to_string(status, pretty_status
, sizeof pretty_status), "\n", errno1, errno_to_name(errno1) ?
: "---", errno2, hstrerror(errno2), ttl) : -abs(_e); })
291 ttl)({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 291, __func__, "%s(\"%s\") → status=%s%-20serrno=%d/%s h_errno=%d/%s ttl=%"
"i", fname, addr_pretty, nss_status_to_string(status, pretty_status
, sizeof pretty_status), "\n", errno1, errno_to_name(errno1) ?
: "---", errno2, hstrerror(errno2), ttl) : -abs(_e); })
;
292 if (status == NSS_STATUS_SUCCESS)
293 print_struct_hostent(&host, NULL((void*)0));
294}
295
296static void test_gethostbyaddr_r(void *handle,
297 const char *module,
298 const void* addr, socklen_t len,
299 int af) {
300
301 const char *fname;
302 _nss_gethostbyaddr_r_t f;
303 char buffer[2000];
304 int errno1 = 999, errno2 = 999; /* nss-dns doesn't set those */
305 enum nss_status status;
306 char pretty_status[DECIMAL_STR_MAX(enum nss_status)(2+(sizeof(enum nss_status) <= 1 ? 3 : sizeof(enum nss_status
) <= 2 ? 5 : sizeof(enum nss_status) <= 4 ? 10 : sizeof
(enum nss_status) <= 8 ? 20 : sizeof(int[-2*(sizeof(enum nss_status
) > 8)])))
];
307 struct hostent host;
308 _cleanup_free___attribute__((cleanup(freep))) char *addr_pretty = NULL((void*)0);
309
310 fname = strjoina("_nss_", module, "_gethostbyaddr_r")({ const char *_appendees_[] = { "_nss_", module, "_gethostbyaddr_r"
}; 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_; })
;
311 f = dlsym(handle, fname);
312
313 log_full_errno(f ? LOG_DEBUG : LOG_INFO, errno,({ int _level = ((f ? 7 : 6)), _e = (((*__errno_location ()))
), _realm = (LOG_REALM_SYSTEMD); (log_get_max_level_realm(_realm
) >= ((_level) & 0x07)) ? log_internal_realm(((_realm)
<< 10 | (_level)), _e, "../src/test/test-nss.c", 314, __func__
, "dlsym(0x%p, %s) → 0x%p: %m", handle, fname, f) : -abs(_e
); })
314 "dlsym(0x%p, %s) → 0x%p: %m", handle, fname, f)({ int _level = ((f ? 7 : 6)), _e = (((*__errno_location ()))
), _realm = (LOG_REALM_SYSTEMD); (log_get_max_level_realm(_realm
) >= ((_level) & 0x07)) ? log_internal_realm(((_realm)
<< 10 | (_level)), _e, "../src/test/test-nss.c", 314, __func__
, "dlsym(0x%p, %s) → 0x%p: %m", handle, fname, f) : -abs(_e
); })
;
315 if (!f)
316 return;
317
318 assert_se(in_addr_to_string(af, addr, &addr_pretty) >= 0)do { if ((__builtin_expect(!!(!(in_addr_to_string(af, addr, &
addr_pretty) >= 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("in_addr_to_string(af, addr, &addr_pretty) >= 0"), "../src/test/test-nss.c"
, 318, __PRETTY_FUNCTION__); } while (0)
;
319
320 status = f(addr, len, af, &host, buffer, sizeof buffer, &errno1, &errno2);
321 log_info("%s(\"%s\") → status=%s%-20serrno=%d/%s h_errno=%d/%s",({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 325, __func__, "%s(\"%s\") → status=%s%-20serrno=%d/%s h_errno=%d/%s"
, fname, addr_pretty, nss_status_to_string(status, pretty_status
, sizeof pretty_status), "\n", errno1, errno_to_name(errno1) ?
: "---", errno2, hstrerror(errno2)) : -abs(_e); })
322 fname, addr_pretty,({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 325, __func__, "%s(\"%s\") → status=%s%-20serrno=%d/%s h_errno=%d/%s"
, fname, addr_pretty, nss_status_to_string(status, pretty_status
, sizeof pretty_status), "\n", errno1, errno_to_name(errno1) ?
: "---", errno2, hstrerror(errno2)) : -abs(_e); })
323 nss_status_to_string(status, pretty_status, sizeof pretty_status), "\n",({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 325, __func__, "%s(\"%s\") → status=%s%-20serrno=%d/%s h_errno=%d/%s"
, fname, addr_pretty, nss_status_to_string(status, pretty_status
, sizeof pretty_status), "\n", errno1, errno_to_name(errno1) ?
: "---", errno2, hstrerror(errno2)) : -abs(_e); })
324 errno1, errno_to_name(errno1) ?: "---",({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 325, __func__, "%s(\"%s\") → status=%s%-20serrno=%d/%s h_errno=%d/%s"
, fname, addr_pretty, nss_status_to_string(status, pretty_status
, sizeof pretty_status), "\n", errno1, errno_to_name(errno1) ?
: "---", errno2, hstrerror(errno2)) : -abs(_e); })
325 errno2, hstrerror(errno2))({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 325, __func__, "%s(\"%s\") → status=%s%-20serrno=%d/%s h_errno=%d/%s"
, fname, addr_pretty, nss_status_to_string(status, pretty_status
, sizeof pretty_status), "\n", errno1, errno_to_name(errno1) ?
: "---", errno2, hstrerror(errno2)) : -abs(_e); })
;
326 if (status == NSS_STATUS_SUCCESS)
327 print_struct_hostent(&host, NULL((void*)0));
328}
329
330static void test_byname(void *handle, const char *module, const char *name) {
331 test_gethostbyname4_r(handle, module, name);
332 puts("");
333
334 test_gethostbyname3_r(handle, module, name, AF_INET2);
335 puts("");
336 test_gethostbyname3_r(handle, module, name, AF_INET610);
337 puts("");
338 test_gethostbyname3_r(handle, module, name, AF_UNSPEC0);
339 puts("");
340 test_gethostbyname3_r(handle, module, name, AF_LOCAL1);
341 puts("");
342
343 test_gethostbyname2_r(handle, module, name, AF_INET2);
344 puts("");
345 test_gethostbyname2_r(handle, module, name, AF_INET610);
346 puts("");
347 test_gethostbyname2_r(handle, module, name, AF_UNSPEC0);
348 puts("");
349 test_gethostbyname2_r(handle, module, name, AF_LOCAL1);
350 puts("");
351
352 test_gethostbyname_r(handle, module, name);
353 puts("");
354}
355
356static void test_byaddr(void *handle,
357 const char *module,
358 const void* addr, socklen_t len,
359 int af) {
360 test_gethostbyaddr2_r(handle, module, addr, len, af);
361 puts("");
362
363 test_gethostbyaddr_r(handle, module, addr, len, af);
364 puts("");
365}
366
367static int make_addresses(struct local_address **addresses) {
368 int n;
369 size_t n_alloc;
370 _cleanup_free___attribute__((cleanup(freep))) struct local_address *addrs = NULL((void*)0);
371
372 n = local_addresses(NULL((void*)0), 0, AF_UNSPEC0, &addrs);
373 if (n < 0)
13
Assuming 'n' is >= 0
14
Taking false branch
374 log_info_errno(n, "Failed to query local addresses: %m")({ int _level = ((6)), _e = ((n)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 374, __func__, "Failed to query local addresses: %m"
) : -abs(_e); })
;
375
376 n_alloc = n; /* we _can_ do that */
377 if (!GREEDY_REALLOC(addrs, n_alloc, n + 3)greedy_realloc((void**) &(addrs), &(n_alloc), (n + 3)
, sizeof((addrs)[0]))
)
15
Assuming the condition is true
16
Taking true branch
378 return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/test/test-nss.c",
378, __func__)
;
17
Returning without writing to '*addresses'
379
380 addrs[n++] = (struct local_address) { .family = AF_INET2,
381 .address.in = { htobe32(0x7F000001)__bswap_32 (0x7F000001) } };
382 addrs[n++] = (struct local_address) { .family = AF_INET2,
383 .address.in = { htobe32(0x7F000002)__bswap_32 (0x7F000002) } };
384 addrs[n++] = (struct local_address) { .family = AF_INET610,
385 .address.in6 = in6addr_loopback };
386 return 0;
387}
388
389static int test_one_module(const char* dir,
390 const char *module,
391 char **names,
392 struct local_address *addresses,
393 int n_addresses) {
394 void *handle;
395 char **name;
396 int i;
397
398 log_info("======== %s ========", module)({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 398, __func__, "======== %s ========"
, module) : -abs(_e); })
;
30
Assuming the condition is false
31
'?' condition is false
399
400 handle = open_handle(streq(module, "dns")(strcmp((module),("dns")) == 0) ? NULL((void*)0) : dir,
32
'?' condition is true
401 module,
402 RTLD_LAZY0x00001|RTLD_NODELETE0x01000);
403 if (!handle)
33
Assuming 'handle' is non-null
34
Taking false branch
404 return -EINVAL22;
405
406 STRV_FOREACH(name, names)for ((name) = (names); (name) && *(name); (name)++)
35
Loop condition is false. Execution continues on line 409
407 test_byname(handle, module, *name);
408
409 for (i = 0; i < n_addresses; i++)
36
Assuming 'i' is < 'n_addresses'
37
Loop condition is true. Entering loop body
410 test_byaddr(handle, module,
411 &addresses[i].address,
412 FAMILY_ADDRESS_SIZE(addresses[i].family),
38
Dereference of null pointer
413 addresses[i].family);
414
415 log_info(" ")({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 415, __func__, " ") : -abs(_e); }
)
;
416 dlclose(handle);
417 return 0;
418}
419
420static int parse_argv(int argc, char **argv,
421 char ***the_modules,
422 char ***the_names,
423 struct local_address **the_addresses, int *n_addresses) {
424
425 int r, n = 0;
426 _cleanup_strv_free___attribute__((cleanup(strv_freep))) char **modules = NULL((void*)0), **names = NULL((void*)0);
427 _cleanup_free___attribute__((cleanup(freep))) struct local_address *addrs = NULL((void*)0);
2
'addrs' initialized to a null pointer value
428 size_t n_allocated = 0;
429
430 if (argc > 1)
3
Assuming 'argc' is <= 1
4
Taking false branch
431 modules = strv_new(argv[1], NULL((void*)0));
432 else
433 modules = strv_new(
434#if ENABLE_NSS_MYHOSTNAME1
435 "myhostname",
436#endif
437#if ENABLE_NSS_RESOLVE1
438 "resolve",
439#endif
440#if ENABLE_NSS_MYMACHINES1
441 "mymachines",
442#endif
443 "dns",
444 NULL((void*)0));
445 if (!modules)
5
Assuming 'modules' is non-null
6
Taking false branch
446 return -ENOMEM12;
447
448 if (argc
6.1
'argc' is <= 2
> 2) {
7
Taking false branch
449 char **name;
450 int family;
451 union in_addr_union address;
452
453 STRV_FOREACH(name, argv + 2)for ((name) = (argv + 2); (name) && *(name); (name)++
)
{
454 r = in_addr_from_string_auto(*name, &family, &address);
455 if (r < 0) {
456 /* assume this is a name */
457 r = strv_extend(&names, *name);
458 if (r < 0)
459 return r;
460 } else {
461 if (!GREEDY_REALLOC0(addrs, n_allocated, n + 1)greedy_realloc0((void**) &(addrs), &(n_allocated), (n
+ 1), sizeof((addrs)[0]))
)
462 return -ENOMEM12;
463
464 addrs[n++] = (struct local_address) { .family = family,
465 .address = address };
466 }
467 }
468 } else {
469 _cleanup_free___attribute__((cleanup(freep))) char *hostname;
470
471 hostname = gethostname_malloc();
472 if (!hostname)
8
Assuming 'hostname' is non-null
9
Taking false branch
473 return -ENOMEM12;
474
475 names = strv_new("localhost", "_gateway", "foo_no_such_host", hostname, NULL((void*)0));
476 if (!names)
10
Assuming 'names' is non-null
11
Taking false branch
477 return -ENOMEM12;
478
479 n = make_addresses(&addrs);
12
Calling 'make_addresses'
18
Returning from 'make_addresses'
480 if (n < 0)
19
Assuming 'n' is >= 0
20
Taking false branch
481 return n;
482 }
483
484 *the_modules = modules;
21
Value assigned to 'modules', which participates in a condition later
485 *the_names = names;
486 modules = names = NULL((void*)0);
487 *the_addresses = addrs;
22
Null pointer value stored to 'addresses'
488 *n_addresses = n;
489 addrs = NULL((void*)0);
490 return 0;
491}
492
493int main(int argc, char **argv) {
494 _cleanup_free___attribute__((cleanup(freep))) char *dir = NULL((void*)0);
495 _cleanup_strv_free___attribute__((cleanup(strv_freep))) char **modules = NULL((void*)0), **names = NULL((void*)0);
496 _cleanup_free___attribute__((cleanup(freep))) struct local_address *addresses = NULL((void*)0);
497 int n_addresses = 0;
498 char **module;
499 int r;
500
501 log_set_max_level(LOG_INFO)log_set_max_level_realm(LOG_REALM_SYSTEMD, (6));
502 log_parse_environment()log_parse_environment_realm(LOG_REALM_SYSTEMD);
503
504 r = parse_argv(argc, argv, &modules, &names, &addresses, &n_addresses);
1
Calling 'parse_argv'
23
Returning from 'parse_argv'
505 if (r
23.1
'r' is >= 0
< 0) {
24
Taking false branch
506 log_error_errno(r, "Failed to parse arguments: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-nss.c", 506, __func__, "Failed to parse arguments: %m"
) : -abs(_e); })
;
507 return EXIT_FAILURE1;
508 }
509
510 dir = dirname_malloc(argv[0]);
511 if (!dir)
25
Assuming 'dir' is non-null
26
Taking false branch
512 return EXIT_FAILURE1;
513
514 STRV_FOREACH(module, modules)for ((module) = (modules); (module) && *(module); (module
)++)
{
27
Loop condition is true. Entering loop body
515 r = test_one_module(dir, *module, names, addresses, n_addresses);
28
Passing null pointer value via 4th parameter 'addresses'
29
Calling 'test_one_module'
516 if (r < 0)
517 return EXIT_FAILURE1;
518 }
519
520 return EXIT_SUCCESS0;
521}