Skip to content

Commit 2551e03

Browse files
mheifacchinm
authored andcommitted
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 <[email protected]>
1 parent 0cee633 commit 2551e03

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libmodbus/modbus.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ int modbus_reply(modbus_t *ctx, const uint8_t *req,
10171017
nb_write, nb, MODBUS_MAX_WR_WRITE_REGISTERS, MODBUS_MAX_WR_READ_REGISTERS);
10181018
} else if (mapping_address < 0 ||
10191019
(mapping_address + nb) > mb_mapping->nb_registers ||
1020-
mapping_address < 0 ||
1020+
mapping_address_write < 0 ||
10211021
(mapping_address_write + nb_write) > mb_mapping->nb_registers) {
10221022
rsp_length = response_exception(
10231023
ctx, &sft, MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS, rsp, FALSE,

0 commit comments

Comments
 (0)