Fix error return code when patching dtb
This commit is contained in:
parent
30eb4074cb
commit
d2e8ecc646
@ -59,15 +59,18 @@ void patch_init_rc(void **buf, size_t *size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int patch_verity(void **buf, uint32_t *size, int patch) {
|
int patch_verity(void **buf, uint32_t *size, int patch) {
|
||||||
int skip, src_size = *size;
|
int skip, src_size = *size, found = 0;
|
||||||
char *src = *buf, *patched = patch ? xcalloc(src_size, 1) : NULL;
|
char *src = *buf, *patched = patch ? xcalloc(src_size, 1) : NULL;
|
||||||
for (int read = 0, write = 0; read < src_size; ++read, ++write) {
|
for (int read = 0, write = 0; read < src_size; ++read, ++write) {
|
||||||
if ((skip = check_verity_pattern(src + read)) > 0) {
|
if ((skip = check_verity_pattern(src + read)) > 0) {
|
||||||
if (!patch)
|
if (patch) {
|
||||||
return 1;
|
|
||||||
fprintf(stderr, "Remove pattern [%.*s]\n", skip, src + read);
|
fprintf(stderr, "Remove pattern [%.*s]\n", skip, src + read);
|
||||||
read += skip;
|
|
||||||
*size -= skip;
|
*size -= skip;
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "Found pattern [%.*s]\n", skip, src + read);
|
||||||
|
}
|
||||||
|
read += skip;
|
||||||
|
found = 1;
|
||||||
}
|
}
|
||||||
if (patch)
|
if (patch)
|
||||||
patched[write] = src[read];
|
patched[write] = src[read];
|
||||||
@ -76,7 +79,7 @@ int patch_verity(void **buf, uint32_t *size, int patch) {
|
|||||||
free(*buf);
|
free(*buf);
|
||||||
*buf = patched;
|
*buf = patched;
|
||||||
}
|
}
|
||||||
return 0;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
void patch_encryption(void **buf, uint32_t *size) {
|
void patch_encryption(void **buf, uint32_t *size) {
|
||||||
|
Loading…
Reference in New Issue
Block a user