mirror of
https://github.com/vgough/encfs.git
synced 2025-01-08 23:18:48 +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);
|
rAssert(_blockSize != 0);
|
||||||
|
|
||||||
off_t fileSize = getSize();
|
off_t fileSize = getSize();
|
||||||
|
if (fileSize < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
// where write request begins
|
// where write request begins
|
||||||
off_t blockNum = req.offset / _blockSize;
|
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)->fileSize = stbuf.st_size;
|
||||||
const_cast<RawFileIO *>(this)->knownSize = true;
|
const_cast<RawFileIO *>(this)->knownSize = true;
|
||||||
return fileSize;
|
return fileSize;
|
||||||
} else
|
} else {
|
||||||
|
rError("getSize on %s failed: %s", name.c_str(), strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return fileSize;
|
return fileSize;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user