]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
machine: fix crash on update from older than v258
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 21 Sep 2025 15:45:14 +0000 (00:45 +0900)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 13 Oct 2025 14:59:40 +0000 (16:59 +0200)
UID entry in the machine state file is introduced in v258,
hence when a host is upgraded to v258, the field does not exist in the
file, thus the variable 'uid' is NULL.

Follow-up for 276d20018623ef14956ce87975be48da5de63f29.
Fixes #39061.

(cherry picked from commit 43cea09f95e5a051432e040c823e945b8b327ed4)

src/machine/machine.c

index 1ce906b7a2ac9440261192f8b0656d7d33659582..84a5e4915f0b84cd3acdc2bd9d91d0668161561e 100644 (file)
@@ -404,9 +404,11 @@ int machine_load(Machine *m) {
                         log_warning_errno(r, "Failed to parse AF_VSOCK CID, ignoring: %s", vsock_cid);
         }
 
-        r = parse_uid(uid, &m->uid);
-        if (r < 0)
-                log_warning_errno(r, "Failed to parse owning UID, ignoring: %s", uid);
+        if (uid) {
+                r = parse_uid(uid, &m->uid);
+                if (r < 0)
+                        log_warning_errno(r, "Failed to parse owning UID, ignoring: %s", uid);
+        }
 
         return r;
 }