소스 검색

Fix test on illegal address in read and write function

Stéphane Raimbault 15 년 전
부모
커밋
6e06eb7d79
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  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,