diff options
author | Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com> | 2022-03-29 17:59:15 +0200 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2022-04-03 16:17:40 +0000 |
commit | d066c4bd4efce5d6b63934e839cff205fffe7af0 (patch) | |
tree | 0e1c8a94f8c354fb6e0b3ee3a68ed97db1631b06 /src | |
parent | de57106c94c31bd3e77a53c92af4654358c2bd19 (diff) | |
download | wayland-d066c4bd4efce5d6b63934e839cff205fffe7af0.tar.gz |
connection: fix asan report on sendmsg call
Initialiaze the entire msghdr struct to 0 before use.
Example of the report fixed with this change:
AddressSanitizer:DEADLYSIGNAL
=================================================================
==20035==ERROR: AddressSanitizer: SEGV on unknown address 0x2dad4dbffffa0d (pc 0x0055555c7488 bp 0x007fffffc760 sp 0x007fffffc760 T0)
==20035==The signal is caused by a READ memory access.
#0 0x55555c7488 in read_msghdr(void*, __sanitizer::__sanitizer_msghdr*, long) (/home/ftrvx/w/_/uxn/bin/uxnemu+0x77488)
#1 0x55555c810c in sendmsg (/home/ftrvx/w/_/uxn/bin/uxnemu+0x7810c)
#2 0x7ff7f2db20 in wl_connection_flush /home/ftrvx/q/wayland/build/../src/connection.c:315:10
#3 0x7ff7f2d014 in wl_display_flush /home/ftrvx/q/wayland/build/../src/wayland-client.c:2154:9
#4 0x7ff7e80bc0 (/lib/libSDL2-2.0.so.0+0x104bc0)
#5 0x7ff7e523b0 (/lib/libSDL2-2.0.so.0+0xd63b0)
#6 0x7ff7e534e4 (/lib/libSDL2-2.0.so.0+0xd74e4)
#7 0x7ff7e535e8 (/lib/libSDL2-2.0.so.0+0xd75e8)
#8 0x7ff7daad54 (/lib/libSDL2-2.0.so.0+0x2ed54)
#9 0x7ff7dab130 (/lib/libSDL2-2.0.so.0+0x2f130)
#10 0x555565bb40 in main /home/ftrvx/w/_/uxn/src/uxnemu.c:519:2
#11 0x7ff7f62484 in libc_start_main_stage2 /builddir/musl-1.1.24/src/env/__libc_start_main.c:94:2
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/home/ftrvx/w/_/uxn/bin/uxnemu+0x77488) in read_msghdr(void*, __sanitizer::__sanitizer_msghdr*, long)
==20035==ABORTING
Signed-off-by: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/connection.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/src/connection.c b/src/connection.c index 3a4ab47..20e2c47 100644 --- a/src/connection.c +++ b/src/connection.c @@ -289,7 +289,7 @@ int wl_connection_flush(struct wl_connection *connection) { struct iovec iov[2]; - struct msghdr msg; + struct msghdr msg = {0}; char cmsg[CLEN]; int len = 0, count, clen; uint32_t tail; @@ -303,13 +303,10 @@ wl_connection_flush(struct wl_connection *connection) build_cmsg(&connection->fds_out, cmsg, &clen); - msg.msg_name = NULL; - msg.msg_namelen = 0; msg.msg_iov = iov; msg.msg_iovlen = count; msg.msg_control = (clen > 0) ? cmsg : NULL; msg.msg_controllen = clen; - msg.msg_flags = 0; do { len = sendmsg(connection->fd, &msg, |