From: Alan Cox Date: Thu, 4 Jun 2015 10:43:14 +0000 (+0100) Subject: readi: Fix sign handling problems X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=fa58fc10bb5e823fc5109d9fc27feadaba6be2e7;p=FUZIX.git readi: Fix sign handling problems We are permitted to write from beyond EOF, but a read from beyond EOF must return 0 --- 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;