Skip to content
This repository has been archived by the owner on Apr 2, 2021. It is now read-only.

modbus: Prevent panic with registers more than max-register apart #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mxinden
Copy link

@mxinden mxinden commented Apr 6, 2019

Modbus supports querying 2000 digital registers or 125 analog registers
at a time. If a user would configure multiple e.g. analog registers,
that can not be quieried with a single query (=> not within 125
distance), then the exporter would try to access indices in the returned
byte slice bigger than the max-register size (125).

This patch:

  • Makes sure to only access indices within the max register size (2000 /
    125).

  • Breaks the loop once all registers have been found.

  • Adds test framework as well as two tests for getModbusData.

  • Adds project binary to .gitignore.

Modbus supports querying 2000 digital registers or 125 analog registers
at a time. If a user would configure multiple e.g. analog registers,
that can not be quieried with a single query (=> not within 125
distance), then the exporter would try to access indices in the returned
byte slice bigger than the max-register size (125).

This patch:

- Makes sure to only access indices within the max register size (2000 /
125).

- Breaks the loop once all registers have been found.

- Adds test framework as well as two tests for `getModbusData`.

- Adds project binary to `.gitignore`.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant