Skip to content

j2534: handle null PassThruOpen parameters - #4

Open
Opriego wants to merge 1 commit into
jeremyhahn:masterfrom
Opriego:fix/passthru-open-null-handling
Open

j2534: handle null PassThruOpen parameters#4
Opriego wants to merge 1 commit into
jeremyhahn:masterfrom
Opriego:fix/passthru-open-null-handling

Conversation

@Opriego

@Opriego Opriego commented Aug 17, 2026

Copy link
Copy Markdown

Summary

  • add isolated regression tests for null PassThruOpen parameters
  • validate pName and pDeviceID before either pointer is used
  • return the J2534-defined ERR_NULL_PARAMETER instead of crashing

Problem

PassThruOpen dereferences pDeviceID in its log statement and calls
strlen(pName) while calculating MQTT topic lengths before checking whether
either pointer is NULL. As a result, invalid required pointers can cause a
segmentation fault instead of returning ERR_NULL_PARAMETER.

Fix

Set j2534_current_api_call and perform the existing null-pointer guard before
the log statement, topic-length calculations, or any other use of the input
pointers.

Testing

The regression test compiles the real src/j2534.c with function/data sections,
links with garbage collection enabled, and stubs only dependencies reachable
from PassThruOpen.

Before the fix:

0%: Checks: 2, Failures: 0, Errors: 2
test_passthru_open_rejects_null_name: Received signal 11
test_passthru_open_rejects_null_device_id: Received signal 11

After the fix:

100%: Checks: 2, Failures: 0, Errors: 0

@Opriego
Opriego force-pushed the fix/passthru-open-null-handling branch from 61ab265 to e0ead75 Compare August 17, 2026 09:39
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