Skip to content

fix(0x11): defer ECUReset hook until secured response sent; skip on send failure#85

Merged
w1ne merged 1 commit into
developfrom
fix/issue76-secured-reset-deferral
Jun 22, 2026
Merged

fix(0x11): defer ECUReset hook until secured response sent; skip on send failure#85
w1ne merged 1 commit into
developfrom
fix/issue76-secured-reset-deferral

Conversation

@w1ne

@w1ne w1ne commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Reworks the secured-deferral hardening from the now-superseded #78 onto current develop (which already has the simpler ordering fix from #82).

Stacked on #84 (the ISO conformance branch), because both touch the ECUReset handler. Base this PR's review on the last commit; merge #84 first, then this retargets cleanly to develop. The diff unique to this PR is the deferral latch + secured-handler wiring + the two new tests.

What #82 left uncovered

The merged #82 sends the 0x51 before fn_reset for a plain ECUReset, but:

  1. 0x84-wrapped resetuds_send_response only captures the inner 0x51; the response the tester actually receives is the outer secured frame, sent later by the 0x84 handler. So a synchronous fn_reset still reboots before the tester is answered.
  2. Send failurefix(0x11): send ECUReset positive response before performing the reset #82 calls fn_reset even when uds_send_response returns an error, leaving the tester with no confirmation but a rebooted ECU.

Fix

  • Deferred-reset latch (ctx->reset_pending / reset_pending_type): the handler runs the reset immediately for an unsecured or suppressed request, but leaves it pending when the response was captured.
  • The 0x84 handler fires the pending reset after the outer secured response is sent, and cancels it if securing fails.
  • A captured ResponseOnEvent (0x86) inner dispatch clears the latch — an event-driven inner dispatch can never trigger a reset.
  • On transport send failure the reset is skipped.
  • uds_reset_fn doc updated; the remaining honest caveat (fn_tp_send = "queued" not "drained") is documented.

Tests

  • test_ecu_reset_secured_defers_until_outer_response — drives a real 0x84-wrapped ECUReset, asserts exactly one real TX (the outer frame) and the reset sequenced strictly after it.
  • test_ecu_reset_no_reset_when_send_fails — failing transport → fn_reset not called.

Both verified red before the fix. Full suite 59/59; cppcheck + clang-format 18 clean.

Supersedes #78.

…end failure

Hardens the send-before-reset ordering (#76) for two cases the merged fix
did not cover:

- SecuredDataTransmission (0x84) wrapping: a 0x11 inner request only has
  its 0x51 captured; the response the tester receives is the outer secured
  frame, sent later by the 0x84 handler. A synchronous fn_reset therefore
  still rebooted before the tester was answered. Add a deferred-reset latch
  (ctx->reset_pending / reset_pending_type): the handler runs the reset
  immediately for an unsecured or suppressed request, but leaves it pending
  when the response was captured. The 0x84 handler fires it after the outer
  secured response is sent, and cancels it if securing fails. A captured
  ROE (0x86) inner dispatch clears the latch so it can never reset.

- Transport send failure: if the positive response cannot be handed to the
  transport, the reset is now skipped so the tester is not left without a
  confirmation.

Document the stronger guarantee on uds_reset_fn. Adds regression tests for
the secured-deferral ordering and the send-failure case (both verified red
before the fix). 59/59 tests pass; cppcheck + clang-format 18 clean.

Refs #76
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.

1 participant