Skip to content

Bugfix/atomic read write file start position - #1362

Merged
skarg merged 4 commits into
masterfrom
bugfix/atomic-read-write-file-start-position
May 27, 2026
Merged

Bugfix/atomic read write file start position#1362
skarg merged 4 commits into
masterfrom
bugfix/atomic-read-write-file-start-position

Conversation

@skarg

@skarg skarg commented May 27, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/bacnet/basic/service/h_awf.h
Comment thread src/bacnet/basic/service/h_arf.c Outdated
Comment thread src/bacnet/basic/object/bacfile.c
@skarg
skarg merged commit c5e3e72 into master May 27, 2026
36 checks passed
@skarg
skarg deleted the bugfix/atomic-read-write-file-start-position branch May 27, 2026 19:49
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.

2 participants