From fa58fc10bb5e823fc5109d9fc27feadaba6be2e7 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Thu, 4 Jun 2015 11:43:14 +0100 Subject: [PATCH] readi: Fix sign handling problems We are permitted to write from beyond EOF, but a read from beyond EOF must return 0 --- Kernel/inode.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Kernel/inode.c b/Kernel/inode.c index c7c3b574..d7bfabb6 100644 --- a/Kernel/inode.c +++ b/Kernel/inode.c @@ -26,9 +26,12 @@ void readi(inoptr ino, uint8_t flag) case F_REG: /* See if end of file will limit read */ - - udata.u_count = min(udata.u_count, + if (ino->c_node.i_size <= udata.u_offset) + udata.u_count = 0; + else { + udata.u_count = min(udata.u_count, ino->c_node.i_size - udata.u_offset); + } toread = udata.u_count; goto loop; -- 2.34.1