[automerger] [DO NOT MERGE] Fix signedness mismatch and integer underflow am: ef35553d53 am: 08bd47e9a9 am: 279cc3d65e am: 972b5551f6

Change-Id: I878947630e3cec949dbfa361a379637a30d67a1d
gugelfrei
Android Build Merger (Role) 6 years ago
commit ded6cb5910

@ -3380,24 +3380,25 @@ int cryptfs_changepw(int crypt_type, const char *newpw)
static unsigned int persist_get_max_entries(int encrypted) { static unsigned int persist_get_max_entries(int encrypted) {
struct crypt_mnt_ftr crypt_ftr; struct crypt_mnt_ftr crypt_ftr;
unsigned int dsize; unsigned int dsize;
unsigned int max_persistent_entries;
/* If encrypted, use the values from the crypt_ftr, otherwise /* If encrypted, use the values from the crypt_ftr, otherwise
* use the values for the current spec. * use the values for the current spec.
*/ */
if (encrypted) { if (encrypted) {
if (get_crypt_ftr_and_key(&crypt_ftr)) { 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; dsize = crypt_ftr.persist_data_size;
} else { } else {
dsize = CRYPT_PERSIST_DATA_SIZE; dsize = CRYPT_PERSIST_DATA_SIZE;
} }
max_persistent_entries = (dsize - sizeof(struct crypt_persist_data)) / if (dsize > sizeof(struct crypt_persist_data)) {
sizeof(struct crypt_persist_entry); return (dsize - sizeof(struct crypt_persist_data)) / sizeof(struct crypt_persist_entry);
} else {
return max_persistent_entries; return 0;
}
} }
static int persist_get_key(const char *fieldname, char *value) static int persist_get_key(const char *fieldname, char *value)

Loading…
Cancel
Save