调用后出现以下错误
free()
的函数
filepaths
(
free(filePaths[i]);
)在运行minSDK=22或更高版本的Android应用程序之后。
minSDK=21上一切正常
传递给空闲的地址0x71db7cb5e0无效:未分配值
我只是想知道minSDK=22或更高版本的Android会发生什么。内存分配是否不同?
static inline void parse_proc_maps_to_fetch_path(char **filepaths);
JNIEXPORT jboolean JNICALL Java_io_github_inflationx_calligraphy_Calligraphy_CalligraphyInterceptor_detectFrida(JNIEnv *env, jobject obj) {
char *filePaths[NUM_LIBS];
globalEnv = env;
parse_proc_maps_to_fetch_path(filePaths);
__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "Libc[%x][%x][%x][%x][%x][%x]", __NR_openat,
__NR_lseek, __NR_read, __NR_close, __NR_readlinkat, __NR_nanosleep);
for (int i = 0; i < NUM_LIBS; i++) {
fetch_checksum_of_library(filePaths[i], &elfSectionArr[i]);
if (filePaths[i] != NULL)
free(filePaths[i]);
}
bool result = false;
pthread_t t;
pthread_create(&t, NULL, (void *) detect_frida_loop, &result);
return result;
}
__attribute__((always_inline))
static inline void parse_proc_maps_to_fetch_path(char **filepaths) {
int fd = 0;
char map[MAX_LINE];
int counter = 0;
if ((fd = my_openat(AT_FDCWD, PROC_MAPS, O_RDONLY | O_CLOEXEC, 0)) != 0) {
while ((read_one_line(fd, map, MAX_LINE)) > 0) {
for (int i = 0; i < NUM_LIBS; i++) {
if (my_strstr(map, libstocheck[i]) != NULL) {
char tmp[MAX_LENGTH] = "";
char path[MAX_LENGTH] = "";
char buf[5] = "";
sscanf(map, "%s %s %s %s %s %s", tmp, buf, tmp, tmp, tmp, path);
if (buf[2] == 'x') {
size_t size = my_strlen(path) + 1;
filepaths[i] = malloc(size);
my_strlcpy(filepaths[i], path, size);
counter++;
}
}
}
if (counter == NUM_LIBS)
break;
}
my_close(fd);
}
}