Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,9 @@ launch.json
# Assitnow token and files for test script
tokens.yaml
*.ubx

# Local development files
.semgrepignore
build_sitl/
CLAUDE.md
brother/
6 changes: 6 additions & 0 deletions src/main/fc/fc_msp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,12 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF
sbufWriteU8(dst, vtxDevice->capability.bandCount);
sbufWriteU8(dst, vtxDevice->capability.channelCount);
sbufWriteU8(dst, vtxDevice->capability.powerCount);

uint8_t minPowerIndex = 1;
if (deviceType == VTXDEV_MSP) {
minPowerIndex = 0;
}
sbufWriteU8(dst, minPowerIndex);
Comment on lines 1528 to +1534
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Adding a new byte to the MSP reply increases the payload size; ensure the destination buffer has room (or update the reply-size calculation) before writing to avoid overruns. [Learned best practice, importance: 6]

Suggested change
sbufWriteU8(dst, vtxDevice->capability.powerCount);
uint8_t minPowerIndex = 1;
if (deviceType == VTXDEV_MSP) {
minPowerIndex = 0;
}
sbufWriteU8(dst, minPowerIndex);
sbufWriteU8(dst, vtxDevice->capability.powerCount);
const uint8_t minPowerIndex = (deviceType == VTXDEV_MSP) ? 0 : 1;
if (sbufBytesRemaining(dst) < 1) {
return false;
}
sbufWriteU8(dst, minPowerIndex);

}
else {
sbufWriteU8(dst, VTXDEV_UNKNOWN); // no VTX configured
Expand Down