mirror of
https://github.com/vgough/encfs.git
synced 2024-11-21 23:43:26 +01:00
Make readOneBlock return -EBADMSG when decode fails
instead of throwing an exception, as with writeOneBlock
This commit is contained in:
parent
63d11e6989
commit
36f3505af0
@ -147,6 +147,10 @@ ssize_t BlockFileIO::read(const IORequest &req) const {
|
||||
}
|
||||
|
||||
ssize_t readSize = cacheReadOneBlock(blockReq);
|
||||
if (readSize < 0) {
|
||||
result = readSize;
|
||||
break;
|
||||
}
|
||||
if (readSize <= partialOffset) break; // didn't get enough bytes
|
||||
|
||||
int cpySize = min((size_t)(readSize - partialOffset), size);
|
||||
|
@ -337,7 +337,7 @@ ssize_t CipherFileIO::readOneBlock(const IORequest &req) const {
|
||||
if (!ok) {
|
||||
VLOG(1) << "decodeBlock failed for block " << blockNum << ", size "
|
||||
<< readSize;
|
||||
readSize = -1;
|
||||
readSize = -EBADMSG;
|
||||
}
|
||||
} else {
|
||||
VLOG(1) << "readSize zero for offset " << req.offset;
|
||||
|
@ -190,7 +190,7 @@ ssize_t MACFileIO::readOneBlock(const IORequest &req) const {
|
||||
RLOG(WARNING) << "MAC comparison failure in block " << blockNum;
|
||||
if (!warnOnly) {
|
||||
MemoryPool::release(mb);
|
||||
throw Error(_("MAC comparison failure, refusing to read"));
|
||||
return -EBADMSG;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user