Commit 6e06eb7d79165a2133b50a6f64ecdceece3ab2c6

Authored by Stéphane Raimbault
1 parent 9a2733e7

Fix test on illegal address in read and write function

Showing 1 changed file with 1 additions and 1 deletions
src/modbus.c
... ... @@ -1142,7 +1142,7 @@ int modbus_reply(modbus_t *ctx, const uint8_t *req,
1142 1142 uint16_t address_write = (req[offset + 5] << 8) + req[offset + 6];
1143 1143 int nb_write = (req[offset + 7] << 8) + req[offset + 8];
1144 1144  
1145   - if ((address + nb) > mb_mapping->nb_registers &&
  1145 + if ((address + nb) > mb_mapping->nb_registers ||
1146 1146 (address_write + nb_write) > mb_mapping->nb_registers) {
1147 1147 if (ctx->debug) {
1148 1148 fprintf(stderr,
... ...