mirror of
https://github.com/vgough/encfs.git
synced 2025-06-21 12:34:02 +02: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);
|
ssize_t readSize = cacheReadOneBlock(blockReq);
|
||||||
|
if (readSize < 0) {
|
||||||
|
result = readSize;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (readSize <= partialOffset) break; // didn't get enough bytes
|
if (readSize <= partialOffset) break; // didn't get enough bytes
|
||||||
|
|
||||||
int cpySize = min((size_t)(readSize - partialOffset), size);
|
int cpySize = min((size_t)(readSize - partialOffset), size);
|
||||||
|
@ -337,7 +337,7 @@ ssize_t CipherFileIO::readOneBlock(const IORequest &req) const {
|
|||||||
if (!ok) {
|
if (!ok) {
|
||||||
VLOG(1) << "decodeBlock failed for block " << blockNum << ", size "
|
VLOG(1) << "decodeBlock failed for block " << blockNum << ", size "
|
||||||
<< readSize;
|
<< readSize;
|
||||||
readSize = -1;
|
readSize = -EBADMSG;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
VLOG(1) << "readSize zero for offset " << req.offset;
|
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;
|
RLOG(WARNING) << "MAC comparison failure in block " << blockNum;
|
||||||
if (!warnOnly) {
|
if (!warnOnly) {
|
||||||
MemoryPool::release(mb);
|
MemoryPool::release(mb);
|
||||||
throw Error(_("MAC comparison failure, refusing to read"));
|
return -EBADMSG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user