mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-12-12 15:39:04 +08:00
Fix CID 1164693 (Untrusted value as argument)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
992031e824
commit
4bb41b8952
@ -50,10 +50,12 @@ bool IndexMap::Serialize(FILE* fp) const {
|
||||
// Reads from the given file. Returns false in case of error.
|
||||
// If swap is true, assumes a big/little-endian swap is needed.
|
||||
bool IndexMap::DeSerialize(bool swap, FILE* fp) {
|
||||
int32_t sparse_size;
|
||||
uint32_t sparse_size;
|
||||
if (fread(&sparse_size, sizeof(sparse_size), 1, fp) != 1) return false;
|
||||
if (swap)
|
||||
ReverseN(&sparse_size, sizeof(sparse_size));
|
||||
// Arbitrarily limit the number of elements to protect against bad data.
|
||||
if (sparse_size > UINT16_MAX) return false;
|
||||
sparse_size_ = sparse_size;
|
||||
if (!compact_map_.DeSerialize(swap, fp)) return false;
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user