From 2b5e93744b1037633ee7876e05a26ca5e3b3c5ba Mon Sep 17 00:00:00 2001 From: Marc Kleine-Budde Date: Sat, 27 Aug 2022 23:26:39 +0200 Subject: [PATCH] candump: reserve enough space for ctrlmsg The ctrlmsg must be large enough to contains 3 elements of various sizes, not a single element of the sum of the size. Signed-off-by: Marc Kleine-Budde --- candump.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/candump.c b/candump.c index 40904cc..f992bb9 100644 --- a/candump.c +++ b/candump.c @@ -303,7 +303,9 @@ int main(int argc, char **argv) int join_filter; char *ptr, *nptr; struct sockaddr_can addr; - char ctrlmsg[CMSG_SPACE(sizeof(struct timeval) + 3 * sizeof(struct timespec) + sizeof(__u32))]; + char ctrlmsg[CMSG_SPACE(sizeof(struct timeval)) + + CMSG_SPACE(3 * sizeof(struct timespec)) + + CMSG_SPACE(sizeof(__u32))]; struct iovec iov; struct msghdr msg; struct cmsghdr *cmsg;