Bugfix/atomic read write file start position - #1362
Merged
Merged
Conversation
…ds checking tests for AtomicReadFile service.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens bounds handling for Atomic Read/Write File operations (stream/record start positions) across the core service handlers and backing file implementations (RAM/posix/SRAM FS), and adds/extends unit tests to verify the new behavior.
Changes:
- Add explicit invalid-start-position guards to AtomicReadFile/AtomicWriteFile logic and underlying file backends (reject negative and out-of-range positions/records).
- Refactor AtomicWriteFile handler to expose an encode helper for testability and add a new functional test suite (
h_awf). - Expand existing FS/unit tests (
bramfs,bsramfs,h_arf) to cover invalid start positions/records.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
test/CMakeLists.txt |
Adds the new h_awf test directory to the overall test build. |
test/bacnet/basic/sys/bsramfs/src/main.c |
Adds coverage for invalid stream/record start inputs for SRAMFS-backed file ops. |
test/bacnet/basic/sys/bramfs/src/main.c |
Adds coverage for invalid stream/record start inputs for RAMFS-backed file ops. |
test/bacnet/basic/service/h_awf/CMakeLists.txt |
Introduces a new functional test target for handler_atomic_write_file bounds checks. |
test/bacnet/basic/service/h_awf/src/main.c |
New tests validating AWF error vs. success responses for invalid/valid start positions. |
test/bacnet/basic/service/h_awf/src/bacfile_stub.c |
Adds bacfile stubs controllable by the AWF tests. |
test/bacnet/basic/service/h_arf/src/main.c |
Extends ARF tests to cover negative/out-of-range start record/position cases. |
test/bacnet/basic/service/h_arf/src/bacfile_stub.c |
Adds a stubbed bacfile_file_size() for ARF stream bounds tests. |
src/bacnet/basic/sys/bsramfs.c |
Adds invalid-start checks for SRAMFS stream/record reads. |
src/bacnet/basic/sys/bramfs.c |
Adds invalid-start checks for RAMFS stream reads and record read/write guards. |
ports/posix/bacfile-posix.c |
Adds invalid-start checks for POSIX stream/record access and tightens open-path selection. |
src/bacnet/basic/service/h_awf.h |
Exposes handler_atomic_write_file_encode() (but currently missing required include). |
src/bacnet/basic/service/h_awf.c |
Refactors AWF logic into an encode helper and adds new invalid-start guards. |
src/bacnet/basic/service/h_arf.c |
Adds file-size-based bounds checking for stream reads and negative record guards. |
src/bacnet/basic/object/bacfile.c |
Adds file-size gating for stream reads and range checks for record reads. |
skarg
added a commit
that referenced
this pull request
May 27, 2026
skarg
added a commit
that referenced
this pull request
May 27, 2026
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.
No description provided.