Skip to content

Commit

Permalink
Fix command parsing for SET_SOURCE_ROUTE_REQ
Browse files Browse the repository at this point in the history
  • Loading branch information
puddly committed May 30, 2024
1 parent 6657ab2 commit 559b587
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ncp-uart-hw/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ EmberStatus emberAfPluginXncpIncomingCustomFrameCallback(uint8_t messageLength,
rsp_command_id = XNCP_CMD_SET_SOURCE_ROUTE_RSP;
rsp_status = EMBER_SUCCESS;

if (messageLength % 2 != 0) {
if ((messageLength < 2) || (messageLength % 2 != 0)) {
rsp_status = EMBER_BAD_ARGUMENT;
break;
}

uint8_t num_relays = messageLength / 2;
uint8_t num_relays = (messageLength - 2) / 2;

if (num_relays > EMBER_MAX_SOURCE_ROUTE_RELAY_COUNT + 1) {
rsp_status = EMBER_BAD_ARGUMENT;
Expand Down

0 comments on commit 559b587

Please sign in to comment.