From 04d376ce2501c18cb7ca435f7a02d80a4a4eba3a Mon Sep 17 00:00:00 2001 From: Nemirtingas Date: Wed, 16 Oct 2019 17:00:08 +0200 Subject: [PATCH 1/2] Fix the address being out of the range lower_bound < addr < upper_bound --- dll/base.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dll/base.cpp b/dll/base.cpp index 72ec0fa..fb7466a 100644 --- a/dll/base.cpp +++ b/dll/base.cpp @@ -158,17 +158,17 @@ std::string get_lib_path() { int i = 0; struct dirent *ep; dp = opendir (dir.c_str()); - unsigned long long int p = (unsigned long long int)&get_lib_path; + intptr_t p = (intptr_t)&get_lib_path; if (dp != NULL) { while ((ep = readdir (dp))) { if (memcmp(ep->d_name, ".", 2) != 0 && memcmp(ep->d_name, "..", 3) != 0) { char *upper = NULL; - unsigned long long int lower_bound = strtoull(ep->d_name, &upper, 16); + intptr_t lower_bound = strtoull(ep->d_name, &upper, 16); if (lower_bound) { ++upper; - unsigned long long int upper_bound = strtoull(upper, &upper, 16); + intptr_t upper_bound = strtoull(upper, &upper, 16); if (upper_bound && (lower_bound < p && p < upper_bound)) { std::string path = dir + PATH_SEPARATOR + ep->d_name; char link[PATH_MAX] = {}; From dbc4e7e08b1a380b330e5eaf46773f3ea6237e71 Mon Sep 17 00:00:00 2001 From: Nemirtingas Date: Wed, 16 Oct 2019 17:31:46 +0000 Subject: [PATCH 2/2] Update base.cpp --- dll/base.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dll/base.cpp b/dll/base.cpp index fb7466a..32a0ab7 100644 --- a/dll/base.cpp +++ b/dll/base.cpp @@ -158,17 +158,17 @@ std::string get_lib_path() { int i = 0; struct dirent *ep; dp = opendir (dir.c_str()); - intptr_t p = (intptr_t)&get_lib_path; + uintptr_t p = (uintptr_t)&get_lib_path; if (dp != NULL) { while ((ep = readdir (dp))) { if (memcmp(ep->d_name, ".", 2) != 0 && memcmp(ep->d_name, "..", 3) != 0) { char *upper = NULL; - intptr_t lower_bound = strtoull(ep->d_name, &upper, 16); + uintptr_t lower_bound = strtoull(ep->d_name, &upper, 16); if (lower_bound) { ++upper; - intptr_t upper_bound = strtoull(upper, &upper, 16); + uintptr_t upper_bound = strtoull(upper, &upper, 16); if (upper_bound && (lower_bound < p && p < upper_bound)) { std::string path = dir + PATH_SEPARATOR + ep->d_name; char link[PATH_MAX] = {};