kfs: fix read offset integer overflow

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

View file

@ -807,7 +807,9 @@ f_read(Chan *cp, Oldfcall *in, Oldfcall *ou)
addr = 0;
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) {
addr = offset / BUFSIZE;

View file

@ -1071,7 +1071,9 @@ fsread(Chan* chan, Fcall* f, Fcall* r)
accessdir(p, d, FREAD);
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){