Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(inputs.modbus): Split large request correctly at field borders #14388

Merged
merged 2 commits into from
Dec 6, 2023

Conversation

srebhan
Copy link
Member

@srebhan srebhan commented Dec 5, 2023

Summary

The modbus plugin splits large requests to adhere to the maximum request size defined by the Modbus spec. Currently, the plugin does so by splitting at the maxBatchSize limit which leads to issues if this limit does not align with a field border.

This PR fixes the code to split the request at a field border, avoiding device addressing errors and invalid field offsets. The PR additionally plays safe when it comes to holding and input offset computation by casting the computed offset to the next higher datatype before multiplication to avoid overflows.

Checklist

  • No AI generated code was used in this PR
  • Unit-test for issue was added

Related issues

resolves #14387

@telegraf-tiger telegraf-tiger bot added area/modbus fix pr to fix corresponding bug plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins labels Dec 5, 2023
@telegraf-tiger
Copy link
Contributor

telegraf-tiger bot commented Dec 5, 2023

@h0d3nt3uf3l
Copy link

Test the fix was successful. Problem solved for me.

@srebhan srebhan added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Dec 6, 2023
@powersj powersj merged commit ea3e6df into influxdata:master Dec 6, 2023
23 checks passed
@github-actions github-actions bot added this to the v1.29.0 milestone Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/modbus fix pr to fix corresponding bug plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

slice bounds out of range
3 participants