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 <mkl@pengutronix.de>
pull/376/head
Marc Kleine-Budde 2022-08-27 23:26:39 +02:00
parent 0d26ba9ea3
commit 2b5e93744b
1 changed files with 3 additions and 1 deletions

View File

@ -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;