mirror of
https://github.com/vgough/encfs.git
synced 2025-01-06 22:18:47 +01:00
Handle getSize errors in BlockFileIO::write
getSize can return -1 if the file was deleted. Just return an error to the user instead of crashing in a segmentation fault.
This commit is contained in:
parent
deba6064ac
commit
ed058fabcd
@ -178,6 +178,8 @@ bool BlockFileIO::write(const IORequest &req) {
|
||||
rAssert(_blockSize != 0);
|
||||
|
||||
off_t fileSize = getSize();
|
||||
if (fileSize < 0)
|
||||
return false;
|
||||
|
||||
// where write request begins
|
||||
off_t blockNum = req.offset / _blockSize;
|
||||
|
@ -178,8 +178,10 @@ off_t RawFileIO::getSize() const {
|
||||
const_cast<RawFileIO *>(this)->fileSize = stbuf.st_size;
|
||||
const_cast<RawFileIO *>(this)->knownSize = true;
|
||||
return fileSize;
|
||||
} else
|
||||
} else {
|
||||
rError("getSize on %s failed: %s", name.c_str(), strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
return fileSize;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user