Skip to content

Validate Modbus frame size before writing the ADU buffer#985

Open
gcormier wants to merge 1 commit into
grblHAL:masterfrom
gcormier:fix-modbus-adu-bounds
Open

Validate Modbus frame size before writing the ADU buffer#985
gcormier wants to merge 1 commit into
grblHAL:masterfrom
gcormier:fix-modbus-adu-bounds

Conversation

@gcormier

Copy link
Copy Markdown
Contributor

modbus_message wrote register values into the fixed-size adu[] buffer before any length validation; the only size check runs later in modbus_send_rtu. A register count above MODBUS_MAX_REGISTERS overran both the caller's values[] array and adu[], and even a multi-register write within the register limit could exceed MODBUS_MAX_ADU_SIZE and write past the buffer.

Reject requests exceeding MODBUS_MAX_REGISTERS, and reject multi-register write frames larger than MODBUS_MAX_ADU_SIZE, before any adu[] write. Single-register reads and writes are unaffected.

modbus_message wrote register values into the fixed-size adu[] buffer
before any length validation; the only size check runs later in
modbus_send_rtu. A register count above MODBUS_MAX_REGISTERS overran
both the caller's values[] array and adu[], and even a multi-register
write within the register limit could exceed MODBUS_MAX_ADU_SIZE and
write past the buffer.

Reject requests exceeding MODBUS_MAX_REGISTERS, and reject multi-register
write frames larger than MODBUS_MAX_ADU_SIZE, before any adu[] write.
Single-register reads and writes are unaffected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant