Correctly convert filesize from Kbyte to byte.

`reader.getFileSize()` return the size of the zim in Kbyte in a
`unsigned int` (32 bits). This is ok as it would overflow if the size
of the size is greater than 4294967295 kbytes (so ~4Tbytes).

However, we need to convert the return size into a unsigned 64 bits integer
else, when converting to bytes, we will overflow at 4Gbytes.
Even in `m_size` is a uint64_t.
This commit is contained in:
Matthieu Gautier 2018-11-12 12:16:05 +01:00
parent cf1cfe774e
commit 4b31842c4a
2 changed files with 2 additions and 2 deletions

View File

@ -87,7 +87,7 @@ void Book::update(const kiwix::Reader& reader)
m_origId = reader.getOrigId();
m_articleCount = reader.getArticleCount();
m_mediaCount = reader.getMediaCount();
m_size = reader.getFileSize() << 10;
m_size = static_cast<uint64_t>(reader.getFileSize()) << 10;
reader.getFavicon(m_favicon, m_faviconMimeType);
}

View File

@ -851,7 +851,7 @@ bool Reader::isCorrupted() const
unsigned int Reader::getFileSize() const
{
zim::File* file = this->getZimFileHandler();
zim::offset_type size = 0;
zim::size_type size = 0;
if (file != NULL) {
size = file->getFilesize();