summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2018-10-19 16:24:52 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2018-10-19 16:24:52 +0000
commit8552340b92cae81dfbb70308f34f257ec59d7af3 (patch)
tree6f3ec2f4ead9850513ca9e97b4bed3a57ceb0d7f
parent496070fdf69caf2e1be1607ef2f2782b3fa170a1 (diff)
parentc2e37da22aadcdb4a5b7f61a61f824ab8e9b8af9 (diff)
downloadvold-oreo-m7-release.tar.gz
Merge cherrypicks of [5313339, 5313437, 5313318, 5313340, 5313282, 5313283, 5313438, 5313284, 5313341, 5313379, 5313380, 5313319, 5313320, 5313321, 5313285, 5313286, 5313287, 5313497, 5313439] into oc-m7-releaseandroid-8.1.0_r52oreo-m7-release
Change-Id: I5d2093bf934226c1113f2a96e1de445a8a1864aa
-rw-r--r--cryptfs.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/cryptfs.cpp b/cryptfs.cpp
index 43c81777..e603c90c 100644
--- a/cryptfs.cpp
+++ b/cryptfs.cpp
@@ -2488,24 +2488,25 @@ int cryptfs_changepw(int crypt_type, const char *newpw)
static unsigned int persist_get_max_entries(int encrypted) {
struct crypt_mnt_ftr crypt_ftr;
unsigned int dsize;
- unsigned int max_persistent_entries;
/* If encrypted, use the values from the crypt_ftr, otherwise
* use the values for the current spec.
*/
if (encrypted) {
if (get_crypt_ftr_and_key(&crypt_ftr)) {
- return -1;
+ /* Something is wrong, assume no space for entries */
+ return 0;
}
dsize = crypt_ftr.persist_data_size;
} else {
dsize = CRYPT_PERSIST_DATA_SIZE;
}
- max_persistent_entries = (dsize - sizeof(struct crypt_persist_data)) /
- sizeof(struct crypt_persist_entry);
-
- return max_persistent_entries;
+ if (dsize > sizeof(struct crypt_persist_data)) {
+ return (dsize - sizeof(struct crypt_persist_data)) / sizeof(struct crypt_persist_entry);
+ } else {
+ return 0;
+ }
}
static int persist_get_key(const char *fieldname, char *value)