]> git.ipfire.org Git - thirdparty/systemd.git/commit
systemd-path: fix memory leak reported by ASAN (#8874)
authorFilipe Brandenburger <filbranden@google.com>
Wed, 2 May 2018 06:47:04 +0000 (23:47 -0700)
committerEvgeny Vereshchagin <evvers@ya.ru>
Wed, 2 May 2018 06:47:04 +0000 (09:47 +0300)
commita605e46f2990a016857618e47afe495af1a2a469
tree6e688b4fdff8efae234272168823440905b6661c
parent2955e0d4dcd670651a55c9372e45b5183f602041
systemd-path: fix memory leak reported by ASAN (#8874)

The leak can be reproduced by running systemd-path --suffix .tmp under valgrind or asan:

    $ ./build/systemd-path --suffix .tmp search-binaries
    /usr/local/bin/.tmp:/usr/bin/.tmp:/usr/local/sbin/.tmp:/usr/sbin/.tmp:/home/vagrant/.local/bin/.tmp:/home/vagrant/bin/.tmp

    =================================================================
    ==19177==ERROR: LeakSanitizer: detected memory leaks

    Direct leak of 56 byte(s) in 1 object(s) allocated from:
        *0 0x7fd6adf72850 in malloc (/lib64/libasan.so.4+0xde850)
        *1 0x7fd6ad2b93d2 in malloc_multiply ../src/basic/alloc-util.h:69
        *2 0x7fd6ad2bafd2 in strv_split ../src/basic/strv.c:269
        *3 0x7fd6ad42ba67 in search_from_environment ../src/libsystemd/sd-path/sd-path.c:409
        *4 0x7fd6ad42bffe in get_search ../src/libsystemd/sd-path/sd-path.c:482
        *5 0x7fd6ad42c55b in sd_path_search ../src/libsystemd/sd-path/sd-path.c:607
        *6 0x7fd6ad42b3a2 in sd_path_home ../src/libsystemd/sd-path/sd-path.c:348
        *7 0x55f59c65ebea in print_home ../src/path/path.c:97
        *8 0x55f59c65f157 in main ../src/path/path.c:177
        *9 0x7fd6abaea009 in __libc_start_main (/lib64/libc.so.6+0x21009)

    Indirect leak of 68 byte(s) in 5 object(s) allocated from:
        *0 0x7fd6adf72850 in malloc (/lib64/libasan.so.4+0xde850)
        *1 0x7fd6abb5f689 in strndup (/lib64/libc.so.6+0x96689)

    Indirect leak of 25 byte(s) in 1 object(s) allocated from:
        *0 0x7fd6adf72850 in malloc (/lib64/libasan.so.4+0xde850)
        *1 0x7fd6abb5f689 in strndup (/lib64/libc.so.6+0x96689)
        *2 0x6c2e2f746e617266  (<unknown module>)

    SUMMARY: AddressSanitizer: 149 byte(s) leaked in 7 allocation(s).
src/libsystemd/sd-path/sd-path.c