mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Better error message when trying to extract a password protected item from a rar archive
This commit is contained in:
parent
a9ae5619ee
commit
78d4515e63
@ -373,6 +373,10 @@ RAR_process_item(RARArchive *self, PyObject *args) {
|
|||||||
self->file_count++;
|
self->file_count++;
|
||||||
try {
|
try {
|
||||||
if (PyObject_IsTrue(extract)) {
|
if (PyObject_IsTrue(extract)) {
|
||||||
|
if ((self->archive->NewLhd.Flags & LHD_PASSWORD) != 0) {
|
||||||
|
PyErr_SetString(UNRARError, "This file is locked with a password.");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
self->DataIO.UnpVolume = false;
|
self->DataIO.UnpVolume = false;
|
||||||
self->DataIO.NextVolumeMissing=false;
|
self->DataIO.NextVolumeMissing=false;
|
||||||
self->DataIO.CurUnpRead=0;
|
self->DataIO.CurUnpRead=0;
|
||||||
@ -421,7 +425,7 @@ RAR_process_item(RARArchive *self, PyObject *args) {
|
|||||||
bool ValidCRC = (self->archive->OldFormat && GET_UINT32(self->DataIO.UnpFileCRC)==GET_UINT32(self->archive->NewLhd.FileCRC)) ||
|
bool ValidCRC = (self->archive->OldFormat && GET_UINT32(self->DataIO.UnpFileCRC)==GET_UINT32(self->archive->NewLhd.FileCRC)) ||
|
||||||
(!self->archive->OldFormat && GET_UINT32(self->DataIO.UnpFileCRC)==GET_UINT32(self->archive->NewLhd.FileCRC^0xffffffff));
|
(!self->archive->OldFormat && GET_UINT32(self->DataIO.UnpFileCRC)==GET_UINT32(self->archive->NewLhd.FileCRC^0xffffffff));
|
||||||
if (!ValidCRC) {
|
if (!ValidCRC) {
|
||||||
PyErr_SetString(UNRARError, "Invalid CRC while extracting item");
|
PyErr_SetString(UNRARError, "Invalid CRC for item");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
// Comes from ProcessFile in dll.cpp
|
// Comes from ProcessFile in dll.cpp
|
||||||
|
Loading…
x
Reference in New Issue
Block a user