ookiineko / magiskboot_build

unofficial magiskboot build system (and port) targeting multi-platform (does not require NDK)
Apache License 2.0
138 stars 22 forks source link

[bug report] CWD containing non ascii char caused crash #25

Closed affggh closed 3 months ago

affggh commented 3 months ago

Hi there , Im using your magiskboot on windows to patch some boot images, but it crashed when the path of the current working directory contains some non ascii characters.

mp中文路径测试.zip

You can easily get crashed with this script.

The log message below may help you

PS D:\my\中文测试> .\busybox.exe ash .\boot_patch.sh boot.img
- Unpacking boot image
Parsing boot image: [boot.img]
HEADER_VER      [4]
KERNEL_SZ       [46771916]
RAMDISK_SZ      [1380092]
OS_VERSION      [12.0.0]
OS_PATCH_LEVEL  [2023-08]
PAGESIZE        [4096]
CMDLINE         []
KERNEL_FMT      [raw]
RAMDISK_FMT     [lz4_legacy]
unexpected ASN.1 DER tag: expected SEQUENCE, got APPLICATION [1] (primitive)
VBMETA
- Checking ramdisk status
Loading cpio: [ramdisk.cpio]
- Stock boot image detected
- Patching ramdisk
./boot_patch.sh: line 174: ./magisk64: Permission denied
./boot_patch.sh: line 179: ./magisk32: Permission denied
Loading cpio: [ramdisk.cpio]
Add file [init] (100750)
Create directory [overlay.d] (0750)
Create directory [overlay.d/sbin] (0750)
Add file [overlay.d/sbin/magisk32.xz] (100644)
Add file [overlay.d/sbin/magisk64.xz] (100644)
Add file [overlay.d/sbin/stub.xz] (100644)
Patch with flag KEEPVERITY=[false] KEEPFORCEENCRYPT=[false]
Loading cpio: [ramdisk.cpio.orig]
Backup [init] -> [.backup/init.xz]
Record new entry: [overlay.d] -> [.backup/.rmlist]
Record new entry: [overlay.d/sbin] -> [.backup/.rmlist]
Record new entry: [overlay.d/sbin/magisk32.xz] -> [.backup/.rmlist]
Record new entry: [overlay.d/sbin/magisk64.xz] -> [.backup/.rmlist]
Record new entry: [overlay.d/sbin/stub.xz] -> [.backup/.rmlist]
Create directory [.backup] (0000)
Add file [.backup/.magisk] (100000)
Dumping cpio: [ramdisk.cpio]
winsup open_compat: unable to convert wide string '\\?\D:\my\': Illegal byte sequence
! Unable to patch ramdisk
ookiineko commented 3 months ago

thanks for reporting. im aware of directly using wcstombs_s is a bad idea since it doesn't say what code page to use.

ookiineko commented 3 months ago

landed in latest releases