Skip to content

fix(blf): reject zero-sized objects instead of looping indefinitely - #2109

Open
timothyanderson096-ocdealcheck wants to merge 2 commits into
hardbyte:mainfrom
timothyanderson096-ocdealcheck:fix/blf-zero-object-size-1584
Open

timothyanderson096-ocdealcheck wants to merge 2 commits into
hardbyte:mainfrom
timothyanderson096-ocdealcheck:fix/blf-zero-object-size-1584

Conversation

@timothyanderson096-ocdealcheck

Copy link
Copy Markdown

Summary of Changes

A zero-sized object inside a BLF log container leaves the parser's next position unchanged. Iterating the reader can therefore repeatedly process the same object without finishing.

  • Reject object sizes smaller than the 16-byte base header with BLFParseError, before decoding or yielding a message.
  • Cover sizes 0, 1 and 15 using an uncompressed BLF file with a modified object header. Each regression fails on the original code without hanging the test runner.
  • Check that valid messages split across log containers still round-trip.
  • Add the required changelog fragment.

Related Issues / Pull Requests

Closes #1584. Thanks to @hotbrakepads for the report.

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactoring
  • Other

Checklist

  • I have followed the contribution guide.
  • I have added tests.
  • I have added a news fragment.
  • All checks and tests pass (tox).

Validation

Validated code/tests are in final content tree 60a6f7de724e0620c340338f6c2df4d4e9ab62e7 (the final follow-up changes only the changelog's Sphinx markup).

  • Reproduced the original infinite iteration in a subprocess, stopped after a two-second timeout. All three new malformed-size regressions fail on the unmodified parser and pass with the fix.
  • python -m pytest test/logformats_test.py::TestBlfFileFormat -q -o addopts='': 16 passed on Python 3.12.14.
  • tox -e lint: passed (Black, Ruff and Pylint project-wide).
  • tox -e type: passed for Python targets 3.10–3.14.
  • tox -e docs: strict HTML build and 39 doctests passed, after correcting the changelog reference.
  • tox -e py312: 507 passed, 98 skipped, 28 failed; 29 subtests passed. Every failure is in the existing IPv4/IPv6 UDP multicast back-to-back classes and reports failure to create/configure the multicast socket. Direct IPv4 and IPv6 multicast probes also fail with OSError: [Errno 101] Network is unreachable in this environment. The full test gate therefore remains unverified; no tests or skips were changed to hide these failures.
  • git diff --check: passed.

Python 3.13.16 was used for the configured lint, type and documentation environments. Windows/macOS and physical CAN validation remain for CI/maintainers.

Additional Notes

The implementation change is two lines. It applies to objects inside log containers and leaves the existing handling of supported messages and cross-container data intact. No vehicle or physical CAN adapter was used.

AI assistance: OpenAI Codex prepared the patch and local verification.


Timothy Anderson — Spotted Ridge Engineering / OC Labs
Using GDN — Global Decision Network
timothyanderson096@gmail.com · Engineering evidence

A zero-sized object leaves the next parser offset unchanged, so iteration
can repeatedly process the same record. Raise BLFParseError before
reading a payload when an object cannot contain its 16-byte base header.

Add regressions for sizes 0, 1 and 15, plus a valid message split across
log containers. Include a changelog fragment for issue hardbyte#1584.

AI-assisted implementation and verification.
Avoid an unresolved Sphinx class reference in the changelog fragment.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T03:28:44.359177Z 3e3bad8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

can.BLFReader: Stuck in infinite loop when obj_size = 0.

1 participant