summaryrefslogtreecommitdiff
path: root/libdiskfs/io-read.c
diff options
context:
space:
mode:
authorMichael I. Bushnell <mib@gnu.org>1994-11-11 18:11:32 +0000
committerMichael I. Bushnell <mib@gnu.org>1994-11-11 18:11:32 +0000
commit3d04d468fce628bd5a9794269e0f2201431120aa (patch)
treee69525da3b53005630c5f7ac723600db149fd8a7 /libdiskfs/io-read.c
parent34e5ef4d29936a9f9884b51238a1bb1dd579c062 (diff)
(diskfs_S_io_read): If OFF is past the end of the file, don't set
MAXREAD to a negative number; that will crash rdwr_internal.
Diffstat (limited to 'libdiskfs/io-read.c')
-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)
{