Bound State_Text resize in state_name_list_write_resizable() - #1518
Merged
Merged
Conversation
A WriteProperty of State_Text[0] (array size) or State_Text[N] to any multistate object (MSV, MSO, MSI) grew the keylist one sorted insert at a time without an upper bound. A single request with a large size blocked the single-threaded server loop for a very long time and could exhaust memory (same class as GHSA-hg85-pmm3-jfcf for Structured View). - Reject a new size of 0 or above BACNET_STATE_NAME_LIST_MAX (default 255) with VALUE_OUT_OF_RANGE; the list is left unchanged. - Reject an auto-expanding element write beyond the maximum with INVALID_ARRAY_INDEX. - Initialize new elements to an empty string instead of NULL so they can always be read back. - Unit test updated and extended.
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved issues were identified.
Review effort: Lite
Findings: None
What changed in this PR
Limits resizable State_Text lists to prevent excessive allocation and initializes new entries as readable empty strings.
Changes:
- Adds a configurable maximum of 255 entries.
- Rejects invalid resize and out-of-range writes.
- Extends tests for bounds and initialization behavior.
| File | Description |
|---|---|
test/bacnet/basic/sys/state_name/src/main.c |
Tests resizing, limits, and empty entries. |
src/bacnet/basic/sys/state_name.h |
Defines the configurable list maximum. |
src/bacnet/basic/sys/state_name.c |
Enforces bounds and initializes new entries. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A WriteProperty of State_Text[0] (array size) or State_Text[N] to any multistate object (MSV, MSO, MSI) grew the keylist one sorted insert at a time without an upper bound. A single request with a large size blocked the single-threaded server loop for a very long time and could exhaust memory (same class as GHSA-hg85-pmm3-jfcf for Structured View).