diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-11-20 18:47:56 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-11-20 18:47:56 +0000 |
commit | 5ce9fe355caf09efdb3679bec620ee486cedb731 (patch) | |
tree | 7364554a491ad9e327206cccabaf718da88a6181 | |
parent | c7069cc922ceebb7db0ce4d69a1037768f96db8a (diff) | |
parent | cc10008887e2c6d8359af1d08c0bce800e8cb8c0 (diff) | |
download | recovery-o-mr1-iot-preview-6.tar.gz |
Merge "root: Fix an issue when volume length from fs_mgr is negative."android-o-mr1-iot-preview-6o-mr1-iot-preview-6
-rw-r--r-- | roots.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -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; } } |