daemon: parse apid/ctid in dlt_daemon_control_set_log_level_v2#864
Open
SoundMatt wants to merge 1 commit into
Open
daemon: parse apid/ctid in dlt_daemon_control_set_log_level_v2#864SoundMatt wants to merge 1 commit into
SoundMatt wants to merge 1 commit into
Conversation
The function never assigned req.apid or req.ctid, so the SET_LOG_LEVEL
V2 control handler never actually parsed the apid/ctid fields out of
the message. The two pre-existing dlt_set_id_v2() calls (filling
req.apid / req.ctid, then filling local apid / ctid from req) were
no-ops because:
- req is zero-initialised (DltServiceSetLogLevelV2 req = {0};), so
req.apid and req.ctid (declared as char * in the struct) start NULL.
- dlt_set_id_v2 early-returns when its destination id is NULL.
Consequences:
- Requests with apidlen = ctidlen = 0 fell through to the else branch
with apid = ctid = NULL, silently no-op'ing.
- Requests with apidlen != 0 dereferenced the still-NULL local apid at
the wildcard / "field-only" branches (apid[apid_length - 1]),
crashing the daemon. Reachable from any client that can speak to the
control socket.
Fix: when each length field is non-zero, point req.apid / req.ctid
directly into msg->databuffer (lifetime is bounded by this function's
stack frame). Then assign the local apid / ctid via plain pointer
assignment so the existing wildcard / field-only branch logic (which
keys off apid == NULL / ctid == NULL) operates on real values.
Closes COVESA#863.
This was referenced May 5, 2026
SoundMatt
added a commit
to SoundMatt/dlt-daemon
that referenced
this pull request
May 5, 2026
Companion fix to the OOB-read fix in this same commit series. The function never assigned req->apid or req->ctid: req is calloc'd, so the char * pointer fields start NULL, and the dlt_set_id_v2(req->apid, ...) call to populate them was a no-op (dlt_set_id_v2 early-returns when its destination is NULL). req->apid / req->ctid stayed NULL and were then passed to dlt_daemon_application_find_v2 and dlt_daemon_context_find_v2 despite req->apidlen / req->ctidlen being non-zero — every non-empty lookup was silently turned into a zero-length one. Replace the no-op dlt_set_id_v2 calls with conditional pointer assignments into msg->databuffer, mirroring the surgical approach taken for set_log_level_v2 in PR COVESA#864 and unregister_context_v2 in PR COVESA#868. The bounds checks added in the previous commit ensure the pointer-into-databuffer assignments are safe. Closes COVESA#870. Related: COVESA#866.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
dlt_daemon_control_set_log_level_v2never actually parsed theapid/ctidfields out of incoming SET_LOG_LEVEL V2 requests:req.apid/req.ctid(declaredchar *inDltServiceSetLogLevelV2) are zero-initialised to NULL.dlt_set_id_v2()calls intended to populate them wereno-ops because
dlt_set_id_v2early-returns when its destination isNULL.
dereferences the still-NULL local
apid/ctid(
apid[apid_length - 1]etc.) when their length is non-zero,crashing the daemon.
Reachable from any client that can talk to the control socket
(dispatched from
dlt_daemon_handle_control_messages_v2).Full analysis in #863.
Fix
When each length field is non-zero, point
req.apid/req.ctiddirectly into
msg->databuffer. Then assign the localapid/ctidpointers via plain assignment so the existing branch logic (which keys
off
apid == NULL/ctid == NULL) operates on real values.reqshares storage with the message buffer only for the duration ofthis function call, so the pointer-into-databuffer trick is lifetime-
safe.
Notes
function): they touch overlapping lines but not in conflicting
ways. Whichever lands first, the other rebases trivially.
end-to-end with a live daemon and crafted control messages. Happy to
add one if maintainers can point me at the right harness.
Closes #863.