From 6e06eb7d79165a2133b50a6f64ecdceece3ab2c6 Mon Sep 17 00:00:00 2001 From: Stéphane Raimbault Date: Tue, 10 Aug 2010 08:44:03 +0200 Subject: [PATCH] Fix test on illegal address in read and write function --- src/modbus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modbus.c b/src/modbus.c index b269203..71ca5be 100644 --- a/src/modbus.c +++ b/src/modbus.c @@ -1142,7 +1142,7 @@ int modbus_reply(modbus_t *ctx, const uint8_t *req, uint16_t address_write = (req[offset + 5] << 8) + req[offset + 6]; int nb_write = (req[offset + 7] << 8) + req[offset + 8]; - if ((address + nb) > mb_mapping->nb_registers && + if ((address + nb) > mb_mapping->nb_registers || (address_write + nb_write) > mb_mapping->nb_registers) { if (ctx->debug) { fprintf(stderr, -- libgit2 0.21.4