]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
coredump: use next_datagram_size_fd instead of ioctl(FIONREAD) (#3237)
authorEvgeny Vereshchagin <evvers@ya.ru>
Wed, 11 May 2016 12:29:24 +0000 (15:29 +0300)
committerLennart Poettering <lennart@poettering.net>
Wed, 11 May 2016 12:29:24 +0000 (14:29 +0200)
We need to be sure that the size returned here actually matches what we will read with recvmsg() next

Fixes #2984

src/coredump/coredump.c

index 01fdcfa9090258e590e9bd755bd6806de9611d19..999de639002ab8ddc89b6cfb6260036c92883658 100644 (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;
                 }