It's not important to check the return value of unlink(2) or even verify
that the file exists. If this code is running, it means the system has
rebooted, and thus the update file, if any, should be removed so that
MagiskManager doesn't keep displaying the same message. We also handle
this before we handle "disable" so that disabled modules don't keep
requesting a reboot to update.
Unlike other common OEMs, Samsung use uppper case partition name.
e.g: /dev/block/platform/11120000.ufs/by-name/SYSTEM
This will cause setup_block() fails to find a match partition.
Thus, we should use strcasecmp instead of strcmp.
Signed-off-by: msdx321 <msdx321@gmail.com>
This fixes an issue where if /system or /vendor was already mounted
prior to magiskinit running, then they would get unmounted.
Signed-off-by: Andrew Gunnerson <andrewgunnerson@gmail.com>
By the flow of unpacking boot image of Chrome OS there will be no kernel file but an dtb image. In that case the dtb image won’t be added when repacking boot image.
Signed-off-by: Shaka Huang <shakalaca@gmail.com>
Should be copy & paste error:
1. boot->r_fmt should be re-checked instead of boot->k_fmt once MTK header was found in ramdisk.
2. ramdisk_size should be restored instead of kernel_size when uncompressed ramdisk was found.
3. Correct header of ramdisk
Signed-off-by: Shaka Huang <shakalaca@gmail.com>
Previously, if `cpio_vec_insert()` needed to replace a file and the file
already exists as the first entry, then a duplicate entry would get
created.
This fixes the bug I reported at:
https://forum.xda-developers.com/showpost.php?p=75449768&postcount=22647
Signed-off-by: Andrew Gunnerson <andrewgunnerson@gmail.com>
Some functions, like `patch_init_rc()`, treat buffers read into memory
as a string instead of a byte buffer. Since the buffers weren't
NULL-terminated, this resulted in out-of-bounds reads and caused crashes
in certain conditions.
THis commit updates fd_full_read() to always NULL-terminate the buffers
so that they can be treated as strings when working with text files.
Signed-off-by: Andrew Gunnerson <andrewgunnerson@gmail.com>