summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2018-10-20 00:21:03 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2018-10-20 00:21:03 +0000
commit96ac6dd24d2252595a251994516f9688b2f467f7 (patch)
tree2a3b56997a1c7a307394d4319f49315815d3e2b0
parentecc27018512ab452192cf074304d6b10ea41b70e (diff)
parent94b9956824ad302da344bf43e8040c28d8b002ab (diff)
downloadvold-pie-qpr1-release.tar.gz
Merge cherrypicks of [5317808, 5317809, 5318498, 5317873, 5318338, 5318195, 5318499, 5317874, 5317875, 5317876, 5318243, 5318244, 5318537, 5318538, 5318539, 5318540, 5318541, 5318542, 5318543, 5318544, 5318545, 5318546, 5315210, 5317756, 5318557, 5318558, 5318559, 5318560, 5318561, 5318339, 5318547, 5318548, 5318549, 5318562, 5318563, 5318564, 5318565, 5318566, 5318172, 5318173, 5318174, 5318550, 5318401, 5318196, 5317889, 5318175, 5318176, 5318577, 5318578, 5318579, 5318580, 5318581, 5318503, 5318390, 5318505, 5318341, 5318551] into pi-qpr1-releaseandroid-9.0.0_r30android-9.0.0_r22android-9.0.0_r21android-9.0.0_r20android-9.0.0_r19pie-qpr1-s3-releasepie-qpr1-s2-releasepie-qpr1-release
Change-Id: Ia6434abde93ea6328659f8f08c3d5dbe4e69291d
-rw-r--r--cryptfs.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/cryptfs.cpp b/cryptfs.cpp
index c5024aeb..5a061bbf 100644
--- a/cryptfs.cpp
+++ b/cryptfs.cpp
@@ -2544,24 +2544,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)