From e0e693c32fdf9c793e236d014f94088f937dbeea Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 27 Nov 2018 20:19:26 -0800 Subject: [PATCH] fastboot: do not die if ANDROID_PRODUCT_OUT undefined When checking for existence of "super_empty.img" to determine if flash image product set is meant for logical partitions, we die if ANDROID_PRODUCT_OUT environment is unset or empty. This check is done before we look at the flash image name to determine if it is a candidate to look at the logical metadata. Instead, allow this check to conservatively fail for now. Test: export ANDROID_PRODUCT_OUT= fastboot flash bootloader Bug: 120041144 Change-Id: I43f124015f9d26c79a0feb9123522432fe937343 Merged-In: I43f124015f9d26c79a0feb9123522432fe937343 --- fastboot/fastboot.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp index e066bfff7..d5e88a792 100644 --- a/fastboot/fastboot.cpp +++ b/fastboot/fastboot.cpp @@ -162,9 +162,17 @@ static Image images[] = { // clang-format on }; -static std::string find_item_given_name(const std::string& img_name) { +static char* get_android_product_out() { char* dir = getenv("ANDROID_PRODUCT_OUT"); if (dir == nullptr || dir[0] == '\0') { + return nullptr; + } + return dir; +} + +static std::string find_item_given_name(const std::string& img_name) { + char* dir = get_android_product_out(); + if (!dir) { die("ANDROID_PRODUCT_OUT not set"); } return std::string(dir) + "/" + img_name; @@ -1508,6 +1516,9 @@ failed: } static bool should_flash_in_userspace(const std::string& partition_name) { + if (!get_android_product_out()) { + return false; + } auto path = find_item_given_name("super_empty.img"); if (path.empty()) { return false;