mount: Fix gcc -fanalyzer warning for parsing androidboot.slot_suffix
authorColin Walters <walters@verbum.org>
Fri, 14 Jul 2023 10:51:34 +0000 (06:51 -0400)
committerColin Walters <walters@verbum.org>
Fri, 14 Jul 2023 10:51:34 +0000 (06:51 -0400)
If the karg wasn't present, we'd do a NULL deref which is undefined
behavior.

src/switchroot/ostree-mount-util.h

index 7c7c6ce18a4fd9f1cd252f5269b6b537e85a1a65..180ab2e4e424d4a4fc9e6f4146f24111c13d761d 100644 (file)
@@ -137,6 +137,9 @@ static inline char *
 get_aboot_root_slot (void)
 {
   autofree char *slot_suffix = read_proc_cmdline_key ("androidboot.slot_suffix");
+  if (!slot_suffix)
+    errx (EXIT_FAILURE, "Missing androidboot.slot_suffix");
+
   if (strcmp (slot_suffix, "_a") == 0)
     return strdup ("/ostree/root.a");
   else if (strcmp (slot_suffix, "_b") == 0)