From: Luca Boccassi Date: Thu, 12 Mar 2026 16:16:30 +0000 (+0000) Subject: portable: avoid passing through ID/version fields to LogExtraFields= when they contai... X-Git-Tag: v260-rc4~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cbea0e34c4932188616632530623247023e55097;p=thirdparty%2Fsystemd.git portable: avoid passing through ID/version fields to LogExtraFields= when they contain control characters Found by Claude Code Review. Follow-up for e8114a4f86efa9a176962bbebbba4cb8b5a1c322 --- diff --git a/src/portable/portable.c b/src/portable/portable.c index df505bbe2d5..a7f3ce9dfd0 100644 --- a/src/portable/portable.c +++ b/src/portable/portable.c @@ -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)