aboutsummaryrefslogtreecommitdiff
path: root/libtokencap/libtokencap.so.c
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-07-21 13:15:59 +0200
committerGitHub <noreply@github.com>2020-07-21 13:15:59 +0200
commitb6e65f98827470745d7df5cf1e38b506b9e839b0 (patch)
tree602abd8c1a1929aebda3f80665ffe02b435fdd00 /libtokencap/libtokencap.so.c
parentfc5cfc6cb309b072a45b991be117c17396e46a89 (diff)
parentc2b04bdf6c596f5d220f27caead20d09452ed42d (diff)
downloadafl++-b6e65f98827470745d7df5cf1e38b506b9e839b0.tar.gz
Merge pull request #461 from AFLplusplus/new_splicing
New splicing
Diffstat (limited to 'libtokencap/libtokencap.so.c')
-rw-r--r--libtokencap/libtokencap.so.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/libtokencap/libtokencap.so.c b/libtokencap/libtokencap.so.c
index 600d2a5d..21bac082 100644
--- a/libtokencap/libtokencap.so.c
+++ b/libtokencap/libtokencap.so.c
@@ -35,7 +35,7 @@
#if !defined __linux__ && !defined __APPLE__ && !defined __FreeBSD__ && \
!defined __OpenBSD__ && !defined __NetBSD__ && !defined __DragonFly__ && \
- !defined(__HAIKU__)
+ !defined(__HAIKU__) && !defined(__sun)
#error "Sorry, this library is unsupported in this platform for now!"
#endif /* !__linux__ && !__APPLE__ && ! __FreeBSD__ && ! __OpenBSD__ && \
!__NetBSD__*/
@@ -52,6 +52,10 @@
#include <sys/mman.h>
#elif defined __HAIKU__
#include <kernel/image.h>
+#elif defined __sun
+ /* For map addresses the old struct is enough */
+ #include <sys/procfs.h>
+ #include <limits.h>
#endif
#include <dlfcn.h>
@@ -237,6 +241,8 @@ static void __tokencap_load_mappings(void) {
image_info ii;
int32_t group = 0;
+ __tokencap_ro_loaded = 1;
+
while (get_next_image_info(0, &group, &ii) == B_OK) {
__tokencap_ro[__tokencap_ro_cnt].st = ii.text;
@@ -246,6 +252,38 @@ static void __tokencap_load_mappings(void) {
}
+#elif defined __sun
+ prmap_t *c, *map;
+ char path[PATH_MAX];
+ ssize_t r;
+ size_t hint;
+ int fd;
+
+ snprintf(path, sizeof(path), "/proc/%ld/map", getpid());
+ fd = open(path, O_RDONLY);
+ hint = (1 << 20);
+ map = malloc(hint);
+
+ __tokencap_ro_loaded = 1;
+
+ for (; (r = pread(fd, map, hint, 0)) == hint;) {
+
+ hint <<= 1;
+ map = realloc(map, hint);
+
+ }
+
+ for (c = map; r > 0; c++, r -= sizeof(prmap_t)) {
+
+ __tokencap_ro[__tokencap_ro_cnt].st = c->pr_vaddr;
+ __tokencap_ro[__tokencap_ro_cnt].en = c->pr_vaddr + c->pr_size;
+
+ if (++__tokencap_ro_cnt == MAX_MAPPINGS) break;
+
+ }
+
+ free(map);
+ close(fd);
#endif
}