From 7cd98cc495ab6ecb405805eda189611d07d66213 Mon Sep 17 00:00:00 2001 From: Evgeny Vereshchagin Date: Thu, 16 Aug 2018 02:06:35 +0000 Subject: [PATCH 1/2] oss-fuzz.sh: just install the shared library The workaround is no longer necessary, because the scripts checking fuzzers have stopped going down to the subdirectories of $OUT and started to look for the string "LLVMFuzzerTestOneInput" to tell fuzzers and random binaries apart. Some more details can be found at https://github.com/google/oss-fuzz/issues/1566. --- tools/oss-fuzz.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/oss-fuzz.sh b/tools/oss-fuzz.sh index 200407fcca..2db5b4cc44 100755 --- a/tools/oss-fuzz.sh +++ b/tools/oss-fuzz.sh @@ -44,8 +44,7 @@ df=$build/dns-fuzzing git clone --depth 1 https://github.com/CZ-NIC/dns-fuzzing $df zip -jqr $OUT/fuzz-dns-packet_seed_corpus.zip $df/packet -# install the private shared library without executable permissions -install -Dt $OUT/src/shared/ -m 0644 $build/src/shared/libsystemd-shared-*.so +install -Dt $OUT/src/shared/ $build/src/shared/libsystemd-shared-*.so find $build -maxdepth 1 -type f -executable -name "fuzz-*" -exec mv {} $OUT \; cp src/fuzz/*.options $OUT From 670e95aecda39c49a9ae9c2544203b628ed34d8b Mon Sep 17 00:00:00 2001 From: Evgeny Vereshchagin Date: Thu, 16 Aug 2018 06:48:06 +0000 Subject: [PATCH 2/2] resolvectl: free the block of memory 'hashed' points to before reusing it This fixes a memory leak: ``` d5070e2f67ededca022f81f2941900606b16f3196b2268e856295f59._openpgpkey.gmail.com: resolve call failed: 'd5070e2f67ededca022f81f2941900606b16f3196b2268e856295f59._openpgpkey.gmail.com' not found ================================================================= ==224==ERROR: LeakSanitizer: detected memory leaks Direct leak of 65 byte(s) in 1 object(s) allocated from: #0 0x7f71b0878850 in malloc (/usr/lib64/libasan.so.4+0xde850) #1 0x7f71afaf69b0 in malloc_multiply ../src/basic/alloc-util.h:63 #2 0x7f71afaf6c95 in hexmem ../src/basic/hexdecoct.c:62 #3 0x7f71afbb574b in string_hashsum ../src/basic/gcrypt-util.c:45 #4 0x56201333e0b9 in string_hashsum_sha256 ../src/basic/gcrypt-util.h:30 #5 0x562013347b63 in resolve_openpgp ../src/resolve/resolvectl.c:908 #6 0x562013348b9f in verb_openpgp ../src/resolve/resolvectl.c:944 #7 0x7f71afbae0b0 in dispatch_verb ../src/basic/verbs.c:119 #8 0x56201335790b in native_main ../src/resolve/resolvectl.c:2947 #9 0x56201335880d in main ../src/resolve/resolvectl.c:3087 #10 0x7f71ad8fcf29 in __libc_start_main (/lib64/libc.so.6+0x20f29) SUMMARY: AddressSanitizer: 65 byte(s) leaked in 1 allocation(s). ``` --- src/resolve/resolvectl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resolve/resolvectl.c b/src/resolve/resolvectl.c index f8372d5e83..1ac4683c5f 100644 --- a/src/resolve/resolvectl.c +++ b/src/resolve/resolvectl.c @@ -919,7 +919,7 @@ static int resolve_openpgp(sd_bus *bus, const char *address) { arg_type ?: DNS_TYPE_OPENPGPKEY, false); if (IN_SET(r, -ENXIO, -ESRCH)) { /* NXDOMAIN or NODATA? */ - hashed = NULL; + hashed = mfree(hashed); r = string_hashsum_sha224(address, domain - 1 - address, &hashed); if (r < 0) return log_error_errno(r, "Hashing failed: %m");