Skip to content

fix: discard oversized syslog records through their delimiter - #218

Merged
huami1314 merged 1 commit into
huami1314:mainfrom
Afloat16:fix/syslog-oversized-record-tail-20261202
Dec 3, 2026
Merged

huami1314 merged 1 commit into
huami1314:mainfrom
Afloat16:fix/syslog-oversized-record-tail-20261202

Conversation

@Afloat16

@Afloat16 Afloat16 commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The device syslog reader intends to discard records larger than 64 KiB. It currently clears the buffer after the 65,537th non-CR byte, then starts buffering the rest of the same record. Its next LF or NUL therefore publishes that suffix as if it were a complete log record. For example, 65,537 a bytes followed by tail\n emit tail to the log callback.

Change

Keep a discard state until the oversized record's LF or NUL delimiter, including across socket reads. The next complete record is processed normally. Move this small framing loop into a shared private module so its exact production implementation can be tested on the host without a device connection.

The existing budget counts raw bytes after CR removal. Exactly 65,536 bytes remain valid, CR handling and LF/NUL framing keep their existing behavior, and incomplete records at EOF are still left unreported. UTF-8 decoding and the C callback stay at the existing device call site. Checking the bound before appending also avoids growing the buffer just to discard it.

Validation

  • Six new framing tests cover the exact boundary, complete oversized-record discard, chunk boundaries, consecutive oversized records, next-record recovery, CR handling, split UTF-8 and incomplete final input.
  • The original complete production loop was copied verbatim into a native host harness that collects its actual C callback bytes. Running these same six tests gives 3 failures and 3 passing controls.
  • Compiling the actual candidate lib.rs test target on Linux gives 9 passed, including the three existing session-lifecycle tests.
  • git diff --check and formatting of the new Rust module pass.

The reproducible original-loop/candidate driver is available in the validation branch.

The upstream Build IPA workflow passed on 38f2cd5606819e44f174134aa2b31581f5736a67, including the native device console build and the application IPA build. Local validation covers record framing and the host session tests; live-device pairing and capture have not been exercised.

@Afloat16
Afloat16 marked this pull request as ready for review December 2, 2026 13:29
@huami1314
huami1314 merged commit c7ed924 into huami1314:main Dec 3, 2026
1 check passed
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