From 6f8e8a6ea41f2fd7ad778798bd1afa77d774a732 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Tue, 28 Aug 2018 13:55:35 +0200 Subject: [PATCH] LwIP: clamp reads to a value that can be expressed in 16 bits There is a bug in the LwIP VFS plugin, the chained buffers used by Lwip use sizes expressed in sixteen bits, and under conditions such as a read of 1<<16 the higher bits are lost and the plugin performs a zero length read, and the application interprets this as a closed connection. Fix #2947 --- repos/libports/src/lib/vfs/lwip/vfs.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/repos/libports/src/lib/vfs/lwip/vfs.cc b/repos/libports/src/lib/vfs/lwip/vfs.cc index 8bc423e6d..4b0dda92e 100644 --- a/repos/libports/src/lib/vfs/lwip/vfs.cc +++ b/repos/libports/src/lib/vfs/lwip/vfs.cc @@ -1775,6 +1775,12 @@ class Lwip::File_system final : public Vfs::File_system char *dst, file_size count, file_size &out_count) override { + /* + * LwIP buffer operations are limited to sizes that + * can be expressed in sixteen bits + */ + count = Genode::min(count, 0xffffU); + out_count = 0; if ((!vfs_handle) ||