]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-selinux: place %m after %[sf] (#4977)
authorEvgeny Vereshchagin <evvers@ya.ru>
Sun, 25 Dec 2016 11:17:22 +0000 (14:17 +0300)
committerLennart Poettering <lennart@poettering.net>
Sun, 25 Dec 2016 11:17:22 +0000 (12:17 +0100)
"%d (%m) %s\n" crashes asan: https://github.com/google/sanitizers/issues/759
So, let's place %m after %s

Fixes:
```
$ ./libtool --mode=execute ./test-selinux
...
============ test_misc ==========
ASAN:DEADLYSIGNAL
=================================================================
==2981==ERROR: AddressSanitizer: SEGV on unknown address 0x000041b58ab3 (pc 0x7fd9c55a0eb2 bp 0x7fffdc2f9640 sp 0x7fffdc2f8d68 T0)
    #0 0x7fd9c55a0eb1  (/lib64/libasan.so.3+0xdeeb1)
    #1 0x7fd9c5550bbf  (/lib64/libasan.so.3+0x8ebbf)
    #2 0x7fd9c5552cdd in __interceptor_vsnprintf (/lib64/libasan.so.3+0x90cdd)
    #3 0x7fd9c5063715 in log_internalv src/basic/log.c:680
    #4 0x7fd9c506390a in log_internal src/basic/log.c:697
    #5 0x561d398181a2 in test_misc src/test/test-selinux.c:81
    #6 0x561d398185e8 in main src/test/test-selinux.c:117
    #7 0x7fd9c493a400 in __libc_start_main (/lib64/libc.so.6+0x20400)
    #8 0x561d39817859 in _start (/home/vagrant/systemd-asan/.libs/lt-test-selinux+0x1859)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/lib64/libasan.so.3+0xdeeb1)
==2981==ABORTING
```

src/test/test-selinux.c

index 7545ad3764ca26fad62a0f65cfecfe819b81a8d8..b676c259134c36926e1b265e8e108f4a5345ad99 100644 (file)
@@ -56,7 +56,7 @@ static void test_loading(void) {
         n1 = now(CLOCK_MONOTONIC);
         r = mac_selinux_init();
         n2 = now(CLOCK_MONOTONIC);
-        log_info_errno(r, "mac_selinux_init → %d (%m) %.2fs", r, (n2 - n1)/1e6);
+        log_info_errno(r, "mac_selinux_init → %d %.2fs (%m)", r, (n2 - n1)/1e6);
 }
 
 static void test_cleanup(void) {
@@ -78,18 +78,18 @@ static void test_misc(const char* fname) {
         log_info("============ %s ==========", __func__);
 
         r = mac_selinux_get_our_label(&label);
-        log_info_errno(r, "mac_selinux_get_our_label → %d (%m), \"%s\"",
+        log_info_errno(r, "mac_selinux_get_our_label → %d, \"%s\" (%m)",
                        r, strnull(label));
 
         r = mac_selinux_get_create_label_from_exe(fname, &label2);
-        log_info_errno(r, "mac_selinux_create_label_from_exe → %d (%m), \"%s\"",
+        log_info_errno(r, "mac_selinux_create_label_from_exe → %d, \"%s\" (%m)",
                        r, strnull(label2));
 
         fd = socket(AF_INET, SOCK_DGRAM, 0);
         assert_se(fd >= 0);
 
         r = mac_selinux_get_child_mls_label(fd, fname, label2, &label3);
-        log_info_errno(r, "mac_selinux_get_child_mls_label → %d (%m), \"%s\"",
+        log_info_errno(r, "mac_selinux_get_child_mls_label → %d, \"%s\" (%m)",
                        r, strnull(label3));
 }