Skip to content

Conversation

@CapnBry
Copy link
Member

@CapnBry CapnBry commented Dec 20, 2025

Prevents out-of-bounds array access if the number of items in a POWER_LEVELS_X array doesn't have as many items as MaxPower - MinPower. Instead of the existing code which returns whatever data is in RAM after the POWER_LEVELS array, this returns the value for MinPower.

# before, with a Nomad modified MaxPower/HighPower to 2000mW
Set parameter [Max Power]=7
SetPwr 120 1  <-- First value is not a valid dBm
SetPwr 120 0

# after
Set parameter [Max Power]=7
SetPwr -17 1  <-- 10mW actual output
SetPwr -18 0

This is for when a user sees the hardware page will let them convert their 10mW device into a 2000mW device simply by changing MaxPower, which then causes the radio to output random power currently-- possibly damaging the PA. Hopefully they will see that their range is low on 2000mW and realize the page is for letting the user know what the hardware can do, and not for telling the hardware what to be.

Also removed an unused variables and don't store pointers to the VALUES array locally. The lookup is fast enough for the frequency that this data will be accessed.

Backport

We can consider backporting this but given this has been like this the entire time we've had Unified firmware, and the relative obscurity of hardware.html, I don't think it is critical enough.

@pkendall64 pkendall64 merged commit 4bc3b04 into ExpressLRS:master Dec 22, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants