]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bootspec: make sure all return values are initialized on return of find_esp_and_warn()
authorLennart Poettering <lennart@poettering.net>
Fri, 11 Feb 2022 21:19:35 +0000 (22:19 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 14 Feb 2022 14:44:07 +0000 (15:44 +0100)
THis makes sure that find_esp_and_warn() + find_xbootldr_and_warn()
follow our usual coding style that on success all return values are
initialized. We got that right in most successful codepaths out of these
functions, but missed the one where the paths are manually overwritten
via env vars.

src/shared/bootspec.c

index 15b77f01b2187d39077690c414d14f6c96c3dbd2..7c74cf6f182ca26b85c0cbefb718da5a80a50564 100644 (file)
@@ -1263,6 +1263,16 @@ int find_esp_and_warn(
 
                 /* Note: when the user explicitly configured things with an env var we won't validate the mount
                  * point. After all we want this to be useful for testing. */
+
+                if (ret_part)
+                        *ret_part = 0;
+                if (ret_pstart)
+                        *ret_pstart = 0;
+                if (ret_psize)
+                        *ret_psize = 0;
+                if (ret_uuid)
+                        *ret_uuid = SD_ID128_NULL;
+
                 goto found;
         }
 
@@ -1489,6 +1499,9 @@ int find_xbootldr_and_warn(
                                                "$SYSTEMD_XBOOTLDR_PATH does not refer to absolute path, refusing to use it: %s",
                                                path);
 
+                if (ret_uuid)
+                        *ret_uuid = SD_ID128_NULL;
+
                 goto found;
         }