From c078e8bea381349dfc2c3a34188603764b0161ff Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 14 Jul 2023 06:51:34 -0400 Subject: [PATCH] mount: Fix gcc -fanalyzer warning for parsing androidboot.slot_suffix If the karg wasn't present, we'd do a NULL deref which is undefined behavior. --- src/switchroot/ostree-mount-util.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/switchroot/ostree-mount-util.h b/src/switchroot/ostree-mount-util.h index 7c7c6ce18a..180ab2e4e4 100644 --- a/src/switchroot/ostree-mount-util.h +++ b/src/switchroot/ostree-mount-util.h @@ -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)