1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-23 17:34:00 +03:00

coredump: use next_datagram_size_fd instead of ioctl(FIONREAD) (#3237)

We need to be sure that the size returned here actually matches what we will read with recvmsg() next

Fixes #2984
This commit is contained in:
Evgeny Vereshchagin 2016-05-11 15:29:24 +03:00 committed by Lennart Poettering
parent 4b273d46bb
commit fe1ef0f86e

View File

@ -739,15 +739,16 @@ static int process_socket(int fd) {
.msg_iovlen = 1,
};
ssize_t n;
int l;
ssize_t l;
if (!GREEDY_REALLOC(iovec, n_iovec_allocated, n_iovec + 3)) {
r = log_oom();
goto finish;
}
if (ioctl(fd, FIONREAD, &l) < 0) {
r = log_error_errno(errno, "FIONREAD failed: %m");
l = next_datagram_size_fd(fd);
if (l < 0) {
r = log_error_errno(l, "Failed to determine datagram size to read: %m");
goto finish;
}