forked from Grouper-AOSP/platform_manifest
-
Notifications
You must be signed in to change notification settings - Fork 13
/
system_vold.patch
61 lines (56 loc) · 2.11 KB
/
system_vold.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
diff --git a/Utils.cpp b/Utils.cpp
index 014055b..43014bd 100644
--- a/Utils.cpp
+++ b/Utils.cpp
@@ -211,17 +211,17 @@ static status_t readMetadata(const std::string& path, std::string& fsType,
for (auto line : output) {
// Extract values from blkid output, if defined
const char* cline = line.c_str();
- char* start = strstr(cline, "TYPE=");
+ char* start = strstr(cline, "TYPE=\"");
if (start != nullptr && sscanf(start + 5, "\"%127[^\"]\"", value) == 1) {
fsType = value;
}
- start = strstr(cline, "UUID=");
+ start = strstr(cline, "UUID=\"");
if (start != nullptr && sscanf(start + 5, "\"%127[^\"]\"", value) == 1) {
fsUuid = value;
}
- start = strstr(cline, "LABEL=");
+ start = strstr(cline, "LABEL=\"");
if (start != nullptr && sscanf(start + 6, "\"%127[^\"]\"", value) == 1) {
fsLabel = value;
}
diff --git a/cryptfs.c b/cryptfs.c
index 2a52336..0854f42 100644
--- a/cryptfs.c
+++ b/cryptfs.c
@@ -3380,24 +3380,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)