]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nspawn: add missing OOM check on gethostname_malloc()
authorSam Leonard <sam.leonard@codethink.co.uk>
Tue, 30 Jan 2024 13:05:38 +0000 (13:05 +0000)
committerLennart Poettering <lennart@poettering.net>
Thu, 8 Feb 2024 15:05:31 +0000 (16:05 +0100)
src/nspawn/nspawn.c

index 6cf2fd1ff527498d1763383c01aeb937099f9428..ae5172853b6aed2a3fafa4f71072346656c8561a 100644 (file)
@@ -3049,9 +3049,11 @@ static int determine_names(void) {
         }
 
         if (!arg_machine) {
-                if (arg_directory && path_equal(arg_directory, "/"))
+                if (arg_directory && path_equal(arg_directory, "/")) {
                         arg_machine = gethostname_malloc();
-                else if (arg_image) {
+                        if (!arg_machine)
+                                return log_oom();
+                } else if (arg_image) {
                         char *e;
 
                         r = path_extract_filename(arg_image, &arg_machine);