mirror of https://github.com/kiwix/libkiwix.git
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:
parent
cf1cfe774e
commit
4b31842c4a
|
@ -87,7 +87,7 @@ void Book::update(const kiwix::Reader& reader)
|
||||||
m_origId = reader.getOrigId();
|
m_origId = reader.getOrigId();
|
||||||
m_articleCount = reader.getArticleCount();
|
m_articleCount = reader.getArticleCount();
|
||||||
m_mediaCount = reader.getMediaCount();
|
m_mediaCount = reader.getMediaCount();
|
||||||
m_size = reader.getFileSize() << 10;
|
m_size = static_cast<uint64_t>(reader.getFileSize()) << 10;
|
||||||
|
|
||||||
reader.getFavicon(m_favicon, m_faviconMimeType);
|
reader.getFavicon(m_favicon, m_faviconMimeType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -851,7 +851,7 @@ bool Reader::isCorrupted() const
|
||||||
unsigned int Reader::getFileSize() const
|
unsigned int Reader::getFileSize() const
|
||||||
{
|
{
|
||||||
zim::File* file = this->getZimFileHandler();
|
zim::File* file = this->getZimFileHandler();
|
||||||
zim::offset_type size = 0;
|
zim::size_type size = 0;
|
||||||
|
|
||||||
if (file != NULL) {
|
if (file != NULL) {
|
||||||
size = file->getFilesize();
|
size = file->getFilesize();
|
||||||
|
|
Loading…
Reference in New Issue