Skip to content

Commit

Permalink
subsys/modbus: Fix potential memory overwrite (coverity)
Browse files Browse the repository at this point in the history
The size of ctx->rx_adu.data is not CONFIG_MODBUS_BUFFER_SIZE. Coverity
flagged the potential overwrite so just use sizeof().

Fixes #33789
Fixes #33792
Fixes #33818

Signed-off-by: David Leach <david.leach@nxp.com>
  • Loading branch information
dleach02 authored and nashif committed Apr 1, 2021
1 parent f2d8b4c commit 3f0da93
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion subsys/modbus/modbus_raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ int modbus_raw_submit_rx(const int iface, const struct modbus_adu *adu)
ctx->rx_adu.unit_id = adu->unit_id;
ctx->rx_adu.fc = adu->fc;
memcpy(ctx->rx_adu.data, adu->data,
MIN(adu->length, CONFIG_MODBUS_BUFFER_SIZE));
MIN(adu->length, sizeof(ctx->rx_adu.data)));
k_work_submit(&ctx->server_work);

return 0;
Expand Down

0 comments on commit 3f0da93

Please sign in to comment.