Skip to content

Commit

Permalink
Fix CID 1164693 (Untrusted value as argument)
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Jul 6, 2018
1 parent 992031e commit 4bb41b8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ccutil/indexmapbidi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4bb41b8

Please sign in to comment.