Procházet zdrojové kódy

Fix test on illegal address in read and write function

Stéphane Raimbault před 15 roky
rodič
revize
6e06eb7d79
1 změnil soubory, kde provedl 1 přidání a 1 odebrání
  1. 1 1
      src/modbus.c

+ 1 - 1
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,