Some code adjustments

This commit is contained in:
topjohnwu
2019-02-24 23:09:34 -05:00
parent 63b18246d8
commit c9fa8118d1
15 changed files with 65 additions and 95 deletions

View File

@@ -31,8 +31,9 @@ static int check_encryption_pattern(const char *s) {
return -1;
}
int patch_verity(void **buf, uint32_t *size, int patch) {
int skip, src_size = *size, found = 0;
bool patch_verity(void **buf, uint32_t *size, bool patch) {
int skip, src_size = *size;
bool found = false;
char *src = (char *) *buf, *patched = patch ? (char *) xcalloc(src_size, 1) : nullptr;
for (int read = 0, write = 0; read < src_size; ++read, ++write) {
if ((skip = check_verity_pattern(src + read)) > 0) {
@@ -43,7 +44,7 @@ int patch_verity(void **buf, uint32_t *size, int patch) {
fprintf(stderr, "Found pattern [%.*s]\n", skip, src + read);
}
read += skip;
found = 1;
found = true;
}
if (patch)
patched[write] = src[read];