mirror of
https://github.com/chiteroman/PlayIntegrityFix.git
synced 2025-01-19 03:22:39 +02:00
Merge pull request #91 from HuskyDG/main
fix zygisk companion crash when fopen fails
This commit is contained in:
commit
8eaa0f2490
@ -1,6 +1,7 @@
|
||||
#include <android/log.h>
|
||||
#include <sys/system_properties.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "zygisk.hpp"
|
||||
#include "shadowhook.h"
|
||||
@ -214,35 +215,43 @@ private:
|
||||
|
||||
static void companion(int fd) {
|
||||
FILE *dex = fopen(DEX_FILE_PATH, "rb");
|
||||
long dexSize = 0;
|
||||
char *dexBuffer = nullptr;
|
||||
long jsonSize = 0;
|
||||
char *jsonBuffer = nullptr;
|
||||
|
||||
if (dex) {
|
||||
fseek(dex, 0, SEEK_END);
|
||||
long dexSize = ftell(dex);
|
||||
dexSize = ftell(dex);
|
||||
fseek(dex, 0, SEEK_SET);
|
||||
|
||||
char dexBuffer[dexSize];
|
||||
dexBuffer = (char*)calloc(1, dexSize);
|
||||
fread(dexBuffer, 1, dexSize, dex);
|
||||
|
||||
fclose(dex);
|
||||
}
|
||||
|
||||
FILE *json = fopen(JSON_FILE_PATH, "r");
|
||||
|
||||
if (json) {
|
||||
fseek(json, 0, SEEK_END);
|
||||
long jsonSize = ftell(json);
|
||||
jsonSize = ftell(json);
|
||||
fseek(json, 0, SEEK_SET);
|
||||
|
||||
char jsonBuffer[jsonSize];
|
||||
jsonBuffer = (char*)calloc(1, jsonSize);
|
||||
fread(jsonBuffer, 1, jsonSize, json);
|
||||
|
||||
fclose(json);
|
||||
|
||||
dexBuffer[dexSize] = 0;
|
||||
jsonBuffer[jsonSize] = 0;
|
||||
}
|
||||
|
||||
write(fd, &dexSize, sizeof(long));
|
||||
write(fd, dexBuffer, dexSize);
|
||||
|
||||
write(fd, &jsonSize, sizeof(long));
|
||||
write(fd, jsonBuffer, jsonSize);
|
||||
|
||||
free(dexBuffer);
|
||||
free(jsonBuffer);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user