'magiskboot hexpatch' will exit with status 1 when nothing patched.

This commit is contained in:
Ian Macdonald
2019-06-08 14:29:30 +02:00
committed by John Wu
parent 8ebd9c8927
commit 8513946e09
3 changed files with 7 additions and 3 deletions

View File

@@ -16,8 +16,9 @@ static void hex2byte(uint8_t *hex, uint8_t *str) {
}
}
void hexpatch(const char *image, const char *from, const char *to) {
int hexpatch(const char *image, const char *from, const char *to) {
int patternsize = strlen(from) / 2, patchsize = strlen(to) / 2;
int patched = 1;
size_t filesize;
uint8_t *file, *pattern, *patch;
mmap_rw(image, file, filesize);
@@ -31,9 +32,12 @@ void hexpatch(const char *image, const char *from, const char *to) {
memset(file + i, 0, patternsize);
memcpy(file + i, patch, patchsize);
i += patternsize - 1;
patched = 0;
}
}
munmap(file, filesize);
free(pattern);
free(patch);
return patched;
}