mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-27 10:57:39 +00:00
Fix crashes when removing verity_key
This commit is contained in:
parent
86f778c0aa
commit
c84023bdc2
@ -35,22 +35,25 @@ public:
|
|||||||
void magisk_cpio::patch(bool keepverity, bool keepforceencrypt) {
|
void magisk_cpio::patch(bool keepverity, bool keepforceencrypt) {
|
||||||
fprintf(stderr, "Patch with flag KEEPVERITY=[%s] KEEPFORCEENCRYPT=[%s]\n",
|
fprintf(stderr, "Patch with flag KEEPVERITY=[%s] KEEPFORCEENCRYPT=[%s]\n",
|
||||||
keepverity ? "true" : "false", keepforceencrypt ? "true" : "false");
|
keepverity ? "true" : "false", keepforceencrypt ? "true" : "false");
|
||||||
for (auto &e : entries) {
|
auto next = entries.begin();
|
||||||
|
decltype(next) cur;
|
||||||
|
while (next != entries.end()) {
|
||||||
|
cur = next;
|
||||||
|
++next;
|
||||||
bool fstab = (!keepverity || !keepforceencrypt) &&
|
bool fstab = (!keepverity || !keepforceencrypt) &&
|
||||||
!str_starts(e.first, ".backup") &&
|
!str_starts(cur->first, ".backup") &&
|
||||||
str_contains(e.first, "fstab") && S_ISREG(e.second->mode);
|
str_contains(cur->first, "fstab") && S_ISREG(cur->second->mode);
|
||||||
if (!keepverity) {
|
if (!keepverity) {
|
||||||
if (fstab) {
|
if (fstab) {
|
||||||
patch_verity(&e.second->data, &e.second->filesize, 1);
|
patch_verity(&cur->second->data, &cur->second->filesize, 1);
|
||||||
} else if (e.first == "verity_key") {
|
} else if (cur->first == "verity_key") {
|
||||||
fprintf(stderr, "Remove [verity_key]\n");
|
rm(cur);
|
||||||
e.second.reset();
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!keepforceencrypt) {
|
if (!keepforceencrypt) {
|
||||||
if (fstab) {
|
if (fstab) {
|
||||||
patch_encryption(&e.second->data, &e.second->filesize);
|
patch_encryption(&cur->second->data, &cur->second->filesize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,8 +109,8 @@ for (str = (char *) buf; str < (char *) buf + size; str = str += strlen(str) + 1
|
|||||||
|
|
||||||
void magisk_cpio::restore() {
|
void magisk_cpio::restore() {
|
||||||
char *file;
|
char *file;
|
||||||
entry_map::iterator cur;
|
|
||||||
auto next = entries.begin();
|
auto next = entries.begin();
|
||||||
|
decltype(next) cur;
|
||||||
while (next != entries.end()) {
|
while (next != entries.end()) {
|
||||||
cur = next;
|
cur = next;
|
||||||
++next;
|
++next;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user