int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_fclose_ FILE *f = NULL;
- _cleanup_(etc_hosts_free) EtcHosts h = {};
+ _cleanup_(etc_hosts_clear) EtcHosts h = {};
if (!getenv("SYSTEMD_LOG_LEVEL"))
log_set_max_level(LOG_CRIT);
free(item);
}
-void etc_hosts_free(EtcHosts *hosts) {
+void etc_hosts_clear(EtcHosts *hosts) {
+ assert(hosts);
+
hosts->by_address = hashmap_free_with_destructor(hosts->by_address, etc_hosts_item_free);
hosts->by_name = hashmap_free_with_destructor(hosts->by_name, etc_hosts_item_by_name_free);
hosts->no_address = set_free_free(hosts->no_address);
}
void manager_etc_hosts_flush(Manager *m) {
- etc_hosts_free(&m->etc_hosts);
+ etc_hosts_clear(&m->etc_hosts);
m->etc_hosts_stat = (struct stat) {};
}
}
int etc_hosts_parse(EtcHosts *hosts, FILE *f) {
- _cleanup_(etc_hosts_free) EtcHosts t = {};
+ _cleanup_(etc_hosts_clear) EtcHosts t = {};
unsigned nr = 0;
int r;
strip_localhost(&t);
- etc_hosts_free(hosts);
+ etc_hosts_clear(hosts);
*hosts = t;
t = (EtcHosts) {}; /* prevent cleanup */
return 0;
} EtcHostsItemByName;
int etc_hosts_parse(EtcHosts *hosts, FILE *f);
-void etc_hosts_free(EtcHosts *hosts);
+void etc_hosts_clear(EtcHosts *hosts);
void manager_etc_hosts_flush(Manager *m);
int manager_etc_hosts_lookup(Manager *m, DnsQuestion* q, DnsAnswer **answer);
return;
}
- _cleanup_(etc_hosts_free) EtcHosts hosts = {};
+ _cleanup_(etc_hosts_clear) EtcHosts hosts = {};
assert_se(etc_hosts_parse(&hosts, f) == 0);
}
assert_se(fflush_and_check(f) >= 0);
rewind(f);
- _cleanup_(etc_hosts_free) EtcHosts hosts = {};
+ _cleanup_(etc_hosts_clear) EtcHosts hosts = {};
assert_se(etc_hosts_parse(&hosts, f) == 0);
EtcHostsItemByName *bn;
}
static void test_parse_file_one(const char *fname) {
- _cleanup_(etc_hosts_free) EtcHosts hosts = {};
+ _cleanup_(etc_hosts_clear) EtcHosts hosts = {};
_cleanup_fclose_ FILE *f;
log_info("/* %s(\"%s\") */", __func__, fname);