Skip to content
Verified Commit 2ebe655d authored by ivan tkachenko's avatar ivan tkachenko 🗯
Browse files

upower: Prevent integer overflow during new brightness computation

Provably, if two integers can fit in 31 bits each, the result of their
multiplication is expressible in 62 bits (let alone 63 available). So,
this should be safe. And the division can't do much harm: the divisor
is always at least 1, and worst case scenario — it would be so big that
the overall results becomes zero.

This code still assumes that the allowed brightness values can fit in 32
bits int, which is not totally unreasonable so far.

BUG: 454161
parent e43367e3
Pipeline #192050 passed with stage
in 1 minute and 9 seconds
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment