From 88084912c81880b642d6b72867b40eeaa1fac7d9 Mon Sep 17 00:00:00 2001 From: Olaf Buddenhagen Date: Mon, 4 Jan 2016 01:08:29 +0100 Subject: [PATCH] Linux: Fix corruption of big transfers on 32 bit systems The wrong size calculation magically worked on 64 bit systems, because 2 * sizeof u32 is the same as sizeof usize there -- but not on 32 bit systems, where this dropped 4 bytes of each full fragment. --- platform/linux/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/linux/mod.rs b/platform/linux/mod.rs index 7ee17c356..84cdf6a30 100644 --- a/platform/linux/mod.rs +++ b/platform/linux/mod.rs @@ -201,7 +201,7 @@ impl UnixSender { &mut maximum_send_size_len as *mut socklen_t) < 0 { return Err(UnixError::last()) } - let bytes_per_fragment = maximum_send_size - (mem::size_of::() + + let bytes_per_fragment = maximum_send_size - (mem::size_of::() * 2 + CMSG_SPACE(cmsg_length as size_t) as usize + 256); // Split up the packet into fragments.