system/vold
修订版 | b1498d1d87c22d7c1cb53461a3991f15e87bc6e9 (tree) |
---|---|
时间 | 2018-10-12 08:10:57 |
作者 | Rubin Xu <rubinxu@goog...> |
Commiter | android-build-merger |
Merge "[DO NOT MERGE] Fix signedness mismatch and integer underflow" into oc-dev
am: 92e63e3f9b
Change-Id: Ia169a9fc152f100a9567f2c47ef5a2e46358aa52
@@ -2495,24 +2495,25 @@ int cryptfs_changepw(int crypt_type, const char *newpw) | ||
2495 | 2495 | static unsigned int persist_get_max_entries(int encrypted) { |
2496 | 2496 | struct crypt_mnt_ftr crypt_ftr; |
2497 | 2497 | unsigned int dsize; |
2498 | - unsigned int max_persistent_entries; | |
2499 | 2498 | |
2500 | 2499 | /* If encrypted, use the values from the crypt_ftr, otherwise |
2501 | 2500 | * use the values for the current spec. |
2502 | 2501 | */ |
2503 | 2502 | if (encrypted) { |
2504 | 2503 | if (get_crypt_ftr_and_key(&crypt_ftr)) { |
2505 | - return -1; | |
2504 | + /* Something is wrong, assume no space for entries */ | |
2505 | + return 0; | |
2506 | 2506 | } |
2507 | 2507 | dsize = crypt_ftr.persist_data_size; |
2508 | 2508 | } else { |
2509 | 2509 | dsize = CRYPT_PERSIST_DATA_SIZE; |
2510 | 2510 | } |
2511 | 2511 | |
2512 | - max_persistent_entries = (dsize - sizeof(struct crypt_persist_data)) / | |
2513 | - sizeof(struct crypt_persist_entry); | |
2514 | - | |
2515 | - return max_persistent_entries; | |
2512 | + if (dsize > sizeof(struct crypt_persist_data)) { | |
2513 | + return (dsize - sizeof(struct crypt_persist_data)) / sizeof(struct crypt_persist_entry); | |
2514 | + } else { | |
2515 | + return 0; | |
2516 | + } | |
2516 | 2517 | } |
2517 | 2518 | |
2518 | 2519 | static int persist_get_key(const char *fieldname, char *value) |