cwfs: fix read offset integer overflow

This commit is contained in:
cinap_lenrek 2012-08-01 01:10:24 +02:00
parent c2304e9329
commit 235f71ba47
2 changed files with 6 additions and 3 deletions

View file

@ -911,8 +911,9 @@ f_read(Chan *cp, Fcall *in, Fcall *ou)
}
goto out;
}
if(offset+count > d->size)
if(offset >= d->size)
count = 0;
else if(offset+count > d->size)
count = d->size - offset;
while(count > 0) {
if(p == 0) {

View file

@ -1017,7 +1017,9 @@ fs_read(Chan* chan, Fcall* f, Fcall* r, uchar* data)
accessdir(p, d, FREAD, file->uid);
if(d->mode & DDIR)
goto dread;
if(offset+count > d->size)
if(offset >= d->size)
count = 0;
else if(offset+count > d->size)
count = d->size - offset;
while(count > 0){
if(p == nil){