cwfs: fix read offset integer overflow
This commit is contained in:
parent
c2304e9329
commit
235f71ba47
2 changed files with 6 additions and 3 deletions
|
@ -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) {
|
||||
|
|
|
@ -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){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue