Stricter validation

This commit is contained in:
topjohnwu
2022-11-22 14:47:37 -08:00
committed by John Wu
parent cd5384f13e
commit ed37ddd570
2 changed files with 22 additions and 3 deletions
+21
View File
@@ -313,6 +313,9 @@ ZygiskModule::ZygiskModule(int id, void *handle, void *entry)
}
bool ZygiskModule::RegisterModuleImpl(ApiTable *api, long *module) {
if (api == nullptr || module == nullptr)
return false;
long api_version = *module;
// Unsupported version
if (api_version > ZYGISK_API_VERSION)
@@ -355,6 +358,24 @@ bool ZygiskModule::RegisterModuleImpl(ApiTable *api, long *module) {
return true;
}
bool ZygiskModule::valid() const {
if (mod.api_version == nullptr)
return false;
switch (*mod.api_version) {
case 4:
// fallthrough
case 3:
// fallthrough
case 2:
// fallthrough
case 1:
return mod.v1->impl && mod.v1->preAppSpecialize && mod.v1->postAppSpecialize &&
mod.v1->preServerSpecialize && mod.v1->postServerSpecialize;
default:
return false;
}
}
int ZygiskModule::connectCompanion() const {
if (int fd = zygisk_request(ZygiskRequest::CONNECT_COMPANION); fd >= 0) {
write_int(fd, id);