Skip to content

Commit e7d8850

Browse files
committed
use absolute paths to load shared libraries
1 parent 3d02de0 commit e7d8850

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

dSploit/jni/dSploitd/handler.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ int load_handlers() {
6969
DIR *d;
7070
struct dirent *de;
7171
handler *h,*tmp;
72-
char *path;
72+
char *path, *cwd;
7373
void *handle;
7474
size_t len;
7575

@@ -80,6 +80,21 @@ int load_handlers() {
8080
return -1;
8181
}
8282

83+
cwd = malloc(PATH_MAX);
84+
85+
if(!cwd) {
86+
print( ERROR, "malloc: %s", strerror(errno));
87+
closedir(d);
88+
return -1;
89+
}
90+
91+
if(!getcwd(cwd, PATH_MAX)) {
92+
print( ERROR, "getcwd: %s", strerror(errno));
93+
free(cwd);
94+
closedir(d);
95+
return -1;
96+
}
97+
8398
while((de=readdir(d))) {
8499
if(!strncmp(de->d_name, ".", 2) || !strncmp(de->d_name, "..", 3)) {
85100
continue;
@@ -90,7 +105,7 @@ int load_handlers() {
90105
if(strncmp(de->d_name + (len - 3), ".so", 3))
91106
continue;
92107

93-
if(asprintf(&path, HANDLERS_DIR "/%s", de->d_name) == -1) {
108+
if(asprintf(&path, "%s/" HANDLERS_DIR "/%s", cwd, de->d_name) == -1) {
94109
print( ERROR, "asprintf: %s", strerror(errno) );
95110
continue;
96111
}
@@ -127,6 +142,8 @@ int load_handlers() {
127142

128143
closedir(d);
129144

145+
free(cwd);
146+
130147
if(!handlers.head) {
131148
print( ERROR, "no handlers found" );
132149
return -1;

0 commit comments

Comments
 (0)