]> 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)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 21 Sep 2025 19:53:57 +0000 (04:53 +0900)
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.

src/machine/machine.c

index 69e7c475af16a9143854b2d4df506603be013833..e651026fa9d5eb5a24fa44e0493f5cc52c70e90d 100644 (file)
@@ -403,9 +403,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;
 }