mirror of
https://review.haiku-os.org/haiku
synced 2025-01-31 18:56:49 +01:00
packagefs: Prevent signed integer overflow in Query::IndexGetWeightedScore.
As the comment already noted, the maximum input score is 2048, and 2048*1024*1024 overflows int32. Subtract 1 from maxFactor to prevent this.
This commit is contained in:
parent
fb25e7349d
commit
2b4a870a7f
@ -97,10 +97,9 @@ struct Query::QueryPolicy {
|
||||
{
|
||||
// should be inversely proportional to the index size; max input score
|
||||
// is 2048
|
||||
static const int32 maxFactor = 1024 * 1024;
|
||||
return score * (maxFactor
|
||||
/ std::min(maxFactor,
|
||||
std::max((int32)1, index.index->CountEntries())));
|
||||
static const int32 maxFactor = (1024 * 1024) - 1;
|
||||
return score * (maxFactor /
|
||||
std::min(maxFactor, std::max((int32)1, index.index->CountEntries())));
|
||||
}
|
||||
|
||||
static type_code IndexGetType(Index& index)
|
||||
|
Loading…
x
Reference in New Issue
Block a user