Skip to content
Permalink
Browse files Browse the repository at this point in the history
modbus_reply: fix copy & paste error in sanity check (fixes #614)
While handling MODBUS_FC_WRITE_AND_READ_REGISTERS, both address offsets
must be checked, i.e. the read and the write address must be within the
mapping range.

At the moment, only the read address was considered, it looks like a
simple copy and paste error, so let's fix it.

Signed-off-by: Michael Heimpold <mhei@heimpold.de>
  • Loading branch information
mhei committed Jan 8, 2022
1 parent bd1c85f commit b4ef4c1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/modbus.c
Expand Up @@ -961,7 +961,7 @@ int modbus_reply(modbus_t *ctx, const uint8_t *req,
nb_write, nb, MODBUS_MAX_WR_WRITE_REGISTERS, MODBUS_MAX_WR_READ_REGISTERS);
} else if (mapping_address < 0 ||
(mapping_address + nb) > mb_mapping->nb_registers ||
mapping_address < 0 ||
mapping_address_write < 0 ||
(mapping_address_write + nb_write) > mb_mapping->nb_registers) {
rsp_length = response_exception(
ctx, &sft, MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS, rsp, FALSE,
Expand Down

0 comments on commit b4ef4c1

Please sign in to comment.