]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
vmspawn: tighten parser of EXIT_STATUS= 38110/head
authorLennart Poettering <lennart@poettering.net>
Mon, 16 Jun 2025 08:52:26 +0000 (10:52 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 8 Jul 2025 04:43:17 +0000 (06:43 +0200)
The EXIT_STATUS is supposed to encapuslate an ANSI C process exit
status, which is 8bit unsigned. Hence parse it as such, do not accept
negative values, or values > 255.

src/vmspawn/vmspawn.c

index 0a3ac892556f2c8fe2fc7c0482f7f3bae45ae771..a3dd1432b2806bbe4f54f91fd4cd6b983e563089 100644 (file)
@@ -727,9 +727,12 @@ static int read_vsock_notify(NotifyConnectionData *d, int fd) {
 
         p = strv_find_startswith(tags, "EXIT_STATUS=");
         if (p) {
-                r = safe_atoi(p, d->exit_status);
+                uint8_t k = 0;
+                r = safe_atou8(p, &k);
                 if (r < 0)
                         log_warning_errno(r, "Failed to parse exit status from %s, ignoring: %m", p);
+                else
+                        *d->exit_status = k;
         }
 
         return 1; /* done */