diff options
author | Bowgo Tsai <bowgotsai@google.com> | 2019-06-10 13:56:02 +0530 |
---|---|---|
committer | AnilKumar Chimata <anilc@codeaurora.org> | 2019-06-18 15:58:06 +0530 |
commit | b06e539ad428438cdf3a7215c41b2a37749a3ec3 (patch) | |
tree | c1b3982aecaac12189fc3d6e4318a10a33797e75 | |
parent | bc52a620fe716974ca1ea1d48c804df15af766ad (diff) |
QcomModulePkg: avb: Fix AvbSlotVerifyData->cmdline might be NULL
When AVB_VBMETA_IMAGE_FLAGS_VERIFICATION_DISABLED is set,
AvbSlotVerifyData->cmdline should be a NUL-terminated string instead of
NULL.
Bug: 119551429
Test: atest libavb_host_unittest
Git-repo: https://source.codeaurora.org/quic/la/platform/external/avb
Git-Commit: 9ba3b6613b4e5130fa01a11d984c6b5f0eb3af05
Change-Id: If9cc5feb4f59b0f6b73b577fbff84bb34e514304
-rw-r--r-- | QcomModulePkg/Library/avb/libavb/avb_slot_verify.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/QcomModulePkg/Library/avb/libavb/avb_slot_verify.c b/QcomModulePkg/Library/avb/libavb/avb_slot_verify.c index b410fec3d6..62bf5f17f6 100644 --- a/QcomModulePkg/Library/avb/libavb/avb_slot_verify.c +++ b/QcomModulePkg/Library/avb/libavb/avb_slot_verify.c @@ -1417,10 +1417,13 @@ AvbSlotVerifyResult avb_slot_verify(AvbOps* ops, if (has_system_partition(ops, ab_suffix)) { slot_data->cmdline = avb_strdup("root=PARTUUID=$(ANDROID_SYSTEM_PARTUUID)"); - if (slot_data->cmdline == NULL) { - ret = AVB_SLOT_VERIFY_RESULT_ERROR_OOM; - goto fail; - } + } 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; } } else { /* Add options - any failure in append_options() is either an @@ -1437,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); |