Эх сурвалжийг харах

Add unit tests for VD-1301 and VD-1302 vulnerabilities

Stéphane Raimbault 5 жил өмнө
parent
commit
ca3fcb1c98
1 өөрчлөгдсөн 16 нэмэгдсэн , 3 устгасан
  1. 16 3
      tests/unit-test-client.c

+ 16 - 3
tests/unit-test-client.c

@@ -802,7 +802,6 @@ int test_server(modbus_t *ctx, int use_backend)
             goto close;
     }
 
-    /* Modbus write and read multiple registers */
     rc = send_crafted_request(ctx, MODBUS_FC_WRITE_AND_READ_REGISTERS,
                               rw_raw_req, RW_RAW_REQ_LEN,
                               MODBUS_MAX_WR_READ_REGISTERS + 1, 0,
@@ -810,8 +809,6 @@ int test_server(modbus_t *ctx, int use_backend)
     if (rc == -1)
         goto close;
 
-    /* Modbus write multiple registers with large number of values but a set a
-       small number of bytes in requests (not nb * 2 as usual). */
     rc = send_crafted_request(ctx, MODBUS_FC_WRITE_MULTIPLE_REGISTERS,
                               write_raw_req, WRITE_RAW_REQ_LEN,
                               MODBUS_MAX_WRITE_REGISTERS + 1, 6,
@@ -826,6 +823,22 @@ int test_server(modbus_t *ctx, int use_backend)
     if (rc == -1)
         goto close;
 
+    /* Modbus write multiple registers with large number of values but a set a
+       small number of bytes in requests (not nb * 2 as usual). */
+    rc = send_crafted_request(ctx, MODBUS_FC_WRITE_MULTIPLE_REGISTERS,
+                              write_raw_req, WRITE_RAW_REQ_LEN,
+                              MODBUS_MAX_WRITE_REGISTERS, 6,
+                              backend_length, backend_offset);
+    if (rc == -1)
+        goto close;
+
+    rc = send_crafted_request(ctx, MODBUS_FC_WRITE_MULTIPLE_COILS,
+                              write_raw_req, WRITE_RAW_REQ_LEN,
+                              MODBUS_MAX_WRITE_BITS, 6,
+                              backend_length, backend_offset);
+    if (rc == -1)
+        goto close;
+
     /* Test invalid function code */
     modbus_send_raw_request(ctx, invalid_fc_raw_req, INVALID_FC_REQ_LEN * sizeof(uint8_t));
     rc = modbus_receive_confirmation(ctx, rsp);