]> git.ipfire.org Git - thirdparty/systemd.git/commit
resolve: dedup entries in /etc/hosts 25658/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 7 Dec 2022 14:39:56 +0000 (23:39 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 13 Dec 2022 11:37:48 +0000 (20:37 +0900)
commit16a6bc5a7a5da2482d96f7dc43da360ceab1c320
tree40eff37251cd9f5e88918171d74ef6f8f8c12f27
parent59dad407a26dcef61cf48b3ed63bc747a3d18c20
resolve: dedup entries in /etc/hosts

This improves the performance of parsing the file and reduces memory pressure.

Running 'fuzz-etc-hosts timeout-strv' with valgrind,

Before:
total heap usage: 321,020 allocs, 321,020 frees, 15,820,387,193 bytes allocated
real    0m23.531s
user    0m21.458s
sys     0m1.961s

After:
total heap usage: 112,408 allocs, 112,408 frees, 7,297,480 bytes allocated
real    0m8.664s
user    0m8.545s
sys     0m0.065s

Hopefully fixes oss-fuzz#47708 (https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=47708).
src/resolve/resolved-etc-hosts.c
src/resolve/resolved-etc-hosts.h
src/resolve/test-resolved-etc-hosts.c
test/fuzz/fuzz-etc-hosts/oss-fuzz-47708 [new file with mode: 0644]