mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-23 18:15:30 +00:00
Fix an UB when cil compile error
This commit is contained in:
parent
66cf2c984a
commit
b2cd24ed1b
@ -100,6 +100,11 @@ bool MagiskInit::patch_sepolicy(const char *file) {
|
||||
if (patch_init)
|
||||
sepol = sepolicy::from_split();
|
||||
|
||||
if (!sepol) {
|
||||
LOGE("Cannot load split cil\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
sepol->magisk_rules();
|
||||
|
||||
// Custom rules
|
||||
|
@ -107,6 +107,20 @@ sepolicy *sepolicy::compile_split() {
|
||||
FILE *f;
|
||||
int policy_ver;
|
||||
const char *cil_file;
|
||||
#if MAGISK_DEBUG
|
||||
cil_set_log_level(CIL_INFO);
|
||||
#endif
|
||||
cil_set_log_handler(+[](int lvl, char* msg) {
|
||||
if (lvl == CIL_ERR) {
|
||||
LOGE("cil: %s", msg);
|
||||
} else if (lvl == CIL_WARN) {
|
||||
LOGW("cil: %s", msg);
|
||||
} else if (lvl == CIL_INFO) {
|
||||
LOGI("cil: %s", msg);
|
||||
} else {
|
||||
LOGD("cil: %s", msg);
|
||||
}
|
||||
});
|
||||
|
||||
cil_db_init(&db);
|
||||
run_finally fin([db_ptr = &db]{ cil_db_destroy(db_ptr); });
|
||||
@ -114,7 +128,7 @@ sepolicy *sepolicy::compile_split() {
|
||||
cil_set_multiple_decls(db, 1);
|
||||
cil_set_disable_neverallow(db, 1);
|
||||
cil_set_target_platform(db, SEPOL_TARGET_SELINUX);
|
||||
cil_set_attrs_expand_generated(db, 0);
|
||||
cil_set_attrs_expand_generated(db, 1);
|
||||
|
||||
f = xfopen(SELINUX_VERSION, "re");
|
||||
fscanf(f, "%d", &policy_ver);
|
||||
|
Loading…
Reference in New Issue
Block a user