diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2018-10-19 16:33:39 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2018-10-19 16:33:39 +0000 |
commit | 146ccc0a6359ea8d69c38892e78a05ed48098133 (patch) | |
tree | 6f3ec2f4ead9850513ca9e97b4bed3a57ceb0d7f | |
parent | 9ba27145645ec7865cbedb68d28bd50ecaaf7442 (diff) | |
parent | 7feb4081eab90be542d90fb7fb7f720ce9d36b6c (diff) | |
download | vold-oreo-m8-release.tar.gz |
Merge cherrypicks of [5313290, 5313323, 5313343, 5313415, 5313291, 5313441, 5313557, 5313344, 5313383, 5313384, 5313324, 5313325, 5313326, 5313294, 5313295, 5313296, 5313498] into oc-m8-releaseandroid-8.1.0_r67android-8.1.0_r65android-8.1.0_r64android-8.1.0_r63android-8.1.0_r62android-8.1.0_r61android-8.1.0_r60android-8.1.0_r53oreo-m8-release
Change-Id: I3eee7260340d3931be48acb455d8a96179a56b99
-rw-r--r-- | cryptfs.cpp | 13 |
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) |