Skip files with inflate errors during ePub decryption
This commit is contained in:
parent
7d161133c3
commit
a623a3d796
|
@ -1010,9 +1010,20 @@ namespace gourou
|
||||||
_clearData[dataOutLength] = 'Z';
|
_clearData[dataOutLength] = 'Z';
|
||||||
clearData.resize(dataOutLength+1);
|
clearData.resize(dataOutLength+1);
|
||||||
|
|
||||||
client->inflate(clearData, inflateData);
|
try
|
||||||
|
{
|
||||||
client->zipWriteFile(zipHandler, encryptedFile, inflateData);
|
client->inflate(clearData, inflateData);
|
||||||
|
client->zipWriteFile(zipHandler, encryptedFile, inflateData);
|
||||||
|
}
|
||||||
|
catch(gourou::Exception& e)
|
||||||
|
{
|
||||||
|
if (e.getErrorCode() == CLIENT_ZIP_ERROR)
|
||||||
|
{
|
||||||
|
GOUROU_LOG(ERROR, e.what() << std::endl << "Skip file " << encryptedFile);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
it->node().parent().remove_child(it->node());
|
it->node().parent().remove_child(it->node());
|
||||||
}
|
}
|
||||||
|
|
|
@ -510,7 +510,12 @@ void DRMProcessorClientImpl::inflate(gourou::ByteArray& data, gourou::ByteArray&
|
||||||
ret = ::inflate(&infstream, Z_FINISH);
|
ret = ::inflate(&infstream, Z_FINISH);
|
||||||
while (ret == Z_OK || ret == Z_STREAM_END || ret == Z_BUF_ERROR)
|
while (ret == Z_OK || ret == Z_STREAM_END || ret == Z_BUF_ERROR)
|
||||||
{
|
{
|
||||||
|
// Real error
|
||||||
|
if (ret == Z_BUF_ERROR && infstream.avail_out == (uInt)dataSize)
|
||||||
|
EXCEPTION(gourou::CLIENT_ZIP_ERROR, "Inflate error, code " << zError(ret) << ", msg " << infstream.msg);
|
||||||
|
|
||||||
result.append(buffer, dataSize-infstream.avail_out);
|
result.append(buffer, dataSize-infstream.avail_out);
|
||||||
|
|
||||||
if ((ret == Z_OK && infstream.avail_out != 0) || ret == Z_STREAM_END)
|
if ((ret == Z_OK && infstream.avail_out != 0) || ret == Z_STREAM_END)
|
||||||
break;
|
break;
|
||||||
infstream.avail_out = (uInt)dataSize; // size of output
|
infstream.avail_out = (uInt)dataSize; // size of output
|
||||||
|
@ -518,7 +523,6 @@ void DRMProcessorClientImpl::inflate(gourou::ByteArray& data, gourou::ByteArray&
|
||||||
ret = ::inflate(&infstream, Z_FINISH);
|
ret = ::inflate(&infstream, Z_FINISH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (ret == Z_STREAM_END)
|
if (ret == Z_STREAM_END)
|
||||||
ret = inflateEnd(&infstream);
|
ret = inflateEnd(&infstream);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user