summaryrefslogtreecommitdiff
path: root/libdiskfs
diff options
context:
space:
mode:
Diffstat (limited to 'libdiskfs')
-rw-r--r--libdiskfs/io-read.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libdiskfs/io-read.c b/libdiskfs/io-read.c
index 59c2b793..b1cca454 100644
--- a/libdiskfs/io-read.c
+++ b/libdiskfs/io-read.c
@@ -48,9 +48,13 @@ diskfs_S_io_read (struct protid *cred,
if (off == -1)
off = cred->po->filepointer;
-
+
if (off + maxread > np->dn_stat.st_size)
- maxread = np->dn_stat.st_size - off;
+ {
+ maxread = np->dn_stat.st_size - off;
+ if (maxread < 0)
+ maxread = 0;
+ }
if (maxread > *datalen)
{