summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJin Qian <jinqian@google.com>2017-11-20 19:54:48 +0100
committerandroid-build-merger <android-build-merger@google.com>2017-11-20 19:54:48 +0100
commit7a1abb9279c1921eae88babc105618a81c452074 (patch)
treed70e31a2f9beeee6d7c677122d7ebef8b9959399
parentMerge "Add libbrotli as a dependency when building applypatch binary" am: c7069cc922 (diff)
parentMerge "root: Fix an issue when volume length from fs_mgr is negative." (diff)
downloadandroid_bootable_recovery-7a1abb9279c1921eae88babc105618a81c452074.tar
android_bootable_recovery-7a1abb9279c1921eae88babc105618a81c452074.tar.gz
android_bootable_recovery-7a1abb9279c1921eae88babc105618a81c452074.tar.bz2
android_bootable_recovery-7a1abb9279c1921eae88babc105618a81c452074.tar.lz
android_bootable_recovery-7a1abb9279c1921eae88babc105618a81c452074.tar.xz
android_bootable_recovery-7a1abb9279c1921eae88babc105618a81c452074.tar.zst
android_bootable_recovery-7a1abb9279c1921eae88babc105618a81c452074.zip
Diffstat (limited to '')
-rw-r--r--roots.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/roots.cpp b/roots.cpp
index 3cc7b4188..eb299ad6b 100644
--- a/roots.cpp
+++ b/roots.cpp
@@ -262,17 +262,20 @@ int format_volume(const char* volume, const char* directory) {
}
int64_t length = 0;
- if (v->length != 0) {
+ if (v->length > 0) {
length = v->length;
- } else if (v->key_loc != nullptr && strcmp(v->key_loc, "footer") == 0) {
+ } else if (v->length < 0 ||
+ (v->key_loc != nullptr && strcmp(v->key_loc, "footer") == 0)) {
android::base::unique_fd fd(open(v->blk_device, O_RDONLY));
if (fd == -1) {
PLOG(ERROR) << "format_volume: failed to open " << v->blk_device;
return -1;
}
- length = get_file_size(fd.get(), CRYPT_FOOTER_OFFSET);
+ length =
+ get_file_size(fd.get(), v->length ? -v->length : CRYPT_FOOTER_OFFSET);
if (length <= 0) {
- LOG(ERROR) << "get_file_size: invalid size " << length << " for " << v->blk_device;
+ LOG(ERROR) << "get_file_size: invalid size " << length << " for "
+ << v->blk_device;
return -1;
}
}