]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
portable: avoid passing through ID/version fields to LogExtraFields= when they contai...
authorLuca Boccassi <luca.boccassi@gmail.com>
Thu, 12 Mar 2026 16:16:30 +0000 (16:16 +0000)
committerLuca Boccassi <luca.boccassi@gmail.com>
Thu, 12 Mar 2026 21:53:28 +0000 (21:53 +0000)
Found by Claude Code Review.

Follow-up for e8114a4f86efa9a176962bbebbba4cb8b5a1c322

src/portable/portable.c

index df505bbe2d5d3c4e8b2b36a9605ceaefdcae9e02..a7f3ce9dfd0527785c171780af688992975be275 100644 (file)
@@ -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)