summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorqctecmdr <qctecmdr@localhost>2019-07-01 23:33:37 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2019-07-01 23:33:37 -0700
commitc7455c404416e84588193c9ad2af0f3bdb19499f (patch)
tree688724d43d25dcca637507b86c78dd36cdfae1bc
parent447f8b25db3495700b5d430ea20385813cc6a203 (diff)
parentb06e539ad428438cdf3a7215c41b2a37749a3ec3 (diff)
Merge "QcomModulePkg: avb: Fix AvbSlotVerifyData->cmdline might be NULL"
-rw-r--r--QcomModulePkg/Library/avb/libavb/avb_slot_verify.c43
1 files changed, 40 insertions, 3 deletions
diff --git a/QcomModulePkg/Library/avb/libavb/avb_slot_verify.c b/QcomModulePkg/Library/avb/libavb/avb_slot_verify.c
index db650e094c..62bf5f17f6 100644
--- a/QcomModulePkg/Library/avb/libavb/avb_slot_verify.c
+++ b/QcomModulePkg/Library/avb/libavb/avb_slot_verify.c
@@ -1280,6 +1280,35 @@ out:
return ret;
}
+static bool has_system_partition(AvbOps* ops, const char* ab_suffix) {
+ char part_name[PART_NAME_MAX_SIZE];
+ char* system_part_name = "system";
+ char guid_buf[37];
+ AvbIOResult io_ret;
+
+ if (!avb_str_concat(part_name,
+ sizeof part_name,
+ system_part_name,
+ avb_strlen(system_part_name),
+ ab_suffix,
+ avb_strlen(ab_suffix))) {
+ avb_error("System partition name and suffix does not fit.\n");
+ return false;
+ }
+
+ io_ret = ops->get_unique_guid_for_partition(
+ ops, part_name, guid_buf, sizeof guid_buf);
+ if (io_ret == AVB_IO_RESULT_ERROR_NO_SUCH_PARTITION) {
+ avb_debug("No system partition.\n");
+ return false;
+ } else if (io_ret != AVB_IO_RESULT_OK) {
+ avb_error("Error getting unique GUID for system partition.\n");
+ return false;
+ }
+
+ return true;
+}
+
AvbSlotVerifyResult avb_slot_verify(AvbOps* ops,
const char* const* requested_partitions,
const char* ab_suffix,
@@ -1382,8 +1411,16 @@ AvbSlotVerifyResult avb_slot_verify(AvbOps* ops,
* that the system partition is mounted.
*/
avb_assert(slot_data->cmdline == NULL);
- slot_data->cmdline =
- avb_strdup("root=PARTUUID=$(ANDROID_SYSTEM_PARTUUID)");
+ // Devices with dynamic partitions won't have system partition.
+ // Instead, it has a large super partition to accommodate *.img files.
+ // See b/119551429 for details.
+ if (has_system_partition(ops, ab_suffix)) {
+ slot_data->cmdline =
+ avb_strdup("root=PARTUUID=$(ANDROID_SYSTEM_PARTUUID)");
+ } else {
+ // The |cmdline| field should be a NUL-terminated string.
+ slot_data->cmdline = avb_strdup("");
+ }
if (slot_data->cmdline == NULL) {
ret = AVB_SLOT_VERIFY_RESULT_ERROR_OOM;
goto fail;
@@ -1403,7 +1440,7 @@ AvbSlotVerifyResult avb_slot_verify(AvbOps* ops,
}
}
/* Substitute $(ANDROID_SYSTEM_PARTUUID) and friends. */
- if (slot_data->cmdline != NULL) {
+ if (slot_data->cmdline != NULL && avb_strlen(slot_data->cmdline) != 0) {
char* new_cmdline;
new_cmdline = sub_cmdline(
ops, slot_data->cmdline, ab_suffix, using_boot_for_vbmeta);