]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
coredump: use a fixed string instead a scope-delimited compound literal
authorZbigniew Jędrzejewski-Szmek <zbyszek@amutable.com>
Mon, 18 May 2026 10:31:46 +0000 (12:31 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@amutable.com>
Mon, 18 May 2026 10:44:45 +0000 (12:44 +0200)
The compound literal (const char[]){'.','.','.'} has block scope
(C99 6.5.2.5p6). Once we leave the if and loop back, copy[1].iov_base
formally points into a destroyed object. Works on GCC/Clang in practice,
but is UB.

Let's do the easy thing and use a string.

Reported by qarmin (Rafał Mikrut).

src/coredump/coredump-send.c

index 0174be69a405604af8bdb4c0e081844d7fbfdffb..4817d82611d4b6cbfd620a8a389726eec9aaefb1 100644 (file)
@@ -57,7 +57,7 @@ int coredump_send(CoredumpContext *context) {
                                          * what we want to send, and the second one contains
                                          * the trailing dots. */
                                         copy[0] = *iovec;
-                                        copy[1] = IOVEC_MAKE(((const char[]){'.', '.', '.'}), 3);
+                                        copy[1] = IOVEC_MAKE_STRING("...");
 
                                         mh.msg_iov = copy;
                                         mh.msg_iovlen = 2;