Force app version not lower than daemon

This commit is contained in:
vvb2060
2022-06-09 12:23:49 +08:00
committed by John Wu
parent a250e2b56c
commit b9c93c66f6
3 changed files with 18 additions and 4 deletions

View File

@@ -1,4 +1,5 @@
#include <base.hpp>
#include <flags.h>
using namespace std;
@@ -95,7 +96,7 @@ struct EOCD {
* This method extracts the first certificate of the first signer
* within the APK v2 signature block.
*/
string read_certificate(int fd) {
string read_certificate(int fd, bool check_version) {
uint32_t size4;
uint64_t size8;
@@ -129,6 +130,19 @@ string read_certificate(int fd) {
}
read(fd, &central_dir_off, sizeof(central_dir_off));
// Read comment
if (check_version) {
uint16_t comment_sz = 0;
read(fd, &comment_sz, sizeof(comment_sz));
string comment;
comment.resize(comment_sz);
read(fd, comment.data(), comment_sz);
if (MAGISK_VER_CODE > parse_int(comment)) {
// Older version of magisk app is not supported
return {};
}
}
// Next, find the start of the APK signing block
{
constexpr int off = sizeof(signing_block::block_sz_) + sizeof(signing_block::magic);