don't leak a file system block if the buf argument to write is invalid

and a usertest
This commit is contained in:
Robert Morris 2019-09-20 13:09:26 -04:00
parent e1a37303c8
commit 7c7ed20822
2 changed files with 46 additions and 2 deletions

View file

@ -505,10 +505,15 @@ writei(struct inode *ip, int user_src, uint64 src, uint off, uint n)
brelse(bp);
}
if(n > 0 && off > ip->size){
ip->size = off;
if(n > 0){
if(off > ip->size)
ip->size = off;
// write the i-node back to disk even if the size didn't change
// because the loop above might have called bmap() and added a new
// block to ip->addrs[].
iupdate(ip);
}
return n;
}