coredump: allow only empty messages after first "sentinel"

This commit is contained in:
Michal Sekletar
2024-10-30 19:45:31 +00:00
committed by Luca Boccassi
parent f7d5d7c593
commit d9fd1d3707
+8 -2
View File
@@ -1151,8 +1151,14 @@ static int process_socket(int fd) {
r = log_error_errno(SYNTHETIC_ERRNO(EBADMSG), "Received unexpected file descriptors.");
goto finish;
} else
cmsg_close_all(&mh);
}
cmsg_close_all(&mh);
/* Only zero length messages are allowed after the first message that carried a file descriptor. */
if (!first) {
r = log_error_errno(SYNTHETIC_ERRNO(EBADMSG), "Received unexpected message with non zero length.");
goto finish;
}
/* Add trailing NUL byte, in case these are strings */
((char*) iovec.iov_base)[n] = 0;