mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 23:34:06 +00:00
Zim: One more check for Zim header
This commit is contained in:
parent
9a5e1e8910
commit
46a34e805c
10
zim.cc
10
zim.cc
|
@ -63,6 +63,7 @@ using BtreeIndexing::IndexInfo;
|
|||
|
||||
DEF_EX_STR( exNotZimFile, "Not an Zim file", Dictionary::Ex )
|
||||
DEF_EX_STR( exCantReadFile, "Can't read file", Dictionary::Ex )
|
||||
DEF_EX_STR( exInvalidZimHeader, "Invalid Zim header", Dictionary::Ex )
|
||||
DEF_EX( exUserAbort, "User abort", Dictionary::Ex )
|
||||
|
||||
|
||||
|
@ -288,6 +289,9 @@ bool ZimFile::open()
|
|||
if( read( reinterpret_cast< char * >( &zimHeader ), sizeof( zimHeader ) ) != sizeof( zimHeader ) )
|
||||
return false;
|
||||
|
||||
if( zimHeader.magicNumber != 0x44D495A || zimHeader.mimeListPos != sizeof( zimHeader ) )
|
||||
return false;
|
||||
|
||||
// Clusters in zim file may be placed in random order.
|
||||
// We create sorted offsets list to calculate clusters size.
|
||||
|
||||
|
@ -1694,11 +1698,15 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
|
||||
df.open();
|
||||
ZIM_header const & zh = df.header();
|
||||
bool new_namespaces = ( zh.majorVersion >= 6 && zh.minorVersion >= 1 );
|
||||
|
||||
if( zh.magicNumber != 0x44D495A )
|
||||
throw exNotZimFile( i->c_str() );
|
||||
|
||||
if( zh.mimeListPos != sizeof( ZIM_header ) )
|
||||
throw exInvalidZimHeader( i->c_str() );
|
||||
|
||||
bool new_namespaces = ( zh.majorVersion >= 6 && zh.minorVersion >= 1 );
|
||||
|
||||
{
|
||||
int n = firstName.lastIndexOf( '/' );
|
||||
initializing.indexingDictionary( firstName.mid( n + 1 ).toUtf8().constData() );
|
||||
|
|
Loading…
Reference in a new issue