mirror of
https://github.com/systemd/systemd.git
synced 2026-08-13 06:32:22 +00:00
portable: avoid passing through ID/version fields to LogExtraFields= when they contain control characters
Found by Claude Code Review.
Follow-up for e8114a4f86
This commit is contained in:
@@ -1382,9 +1382,19 @@ static int append_release_log_fields(
|
||||
|
||||
/* Find an ID first, in order of preference from more specific to less specific: IMAGE_ID -> ID */
|
||||
id = strv_find_first_field((char *const *)field_ids[type], fields);
|
||||
if (id && string_has_cc(id, /* ok= */ NULL)) {
|
||||
log_debug("os-release file '%s' contains control characters in the ID field, skipping.",
|
||||
release->name);
|
||||
id = NULL;
|
||||
}
|
||||
|
||||
/* Then the version, same logic, prefer the more specific one */
|
||||
version = strv_find_first_field((char *const *)field_versions[type], fields);
|
||||
if (version && string_has_cc(version, /* ok= */ NULL)) {
|
||||
log_debug("os-release file '%s' contains control characters in the version field, skipping.",
|
||||
release->name);
|
||||
version = NULL;
|
||||
}
|
||||
|
||||
/* If there's no valid version to be found, simply omit it. */
|
||||
if (!id && !version)
|
||||
|
||||
Reference in New Issue
Block a user