From b7173a191ad477219b713cb5e3d2815ca8ab290f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 16 Jul 2018 19:35:17 +0000 Subject: use memrchr to extract address under glibc glibc will place the (virtual) address at the end, and this allows us to find addresses for programs which put '[' in their progname (e.g. ssh, mogilefsd, unicorn, avahi, ...) --- ext/mwrap/mwrap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/mwrap/mwrap.c b/ext/mwrap/mwrap.c index 421c086..0a1f9b5 100644 --- a/ext/mwrap/mwrap.c +++ b/ext/mwrap/mwrap.c @@ -839,7 +839,7 @@ extract_addr(const char *str, size_t len, void **p) { const char *c; #if defined(__GLIBC__) - return ((c = memchr(str, '[', len)) && sscanf(c, "[%p]", p)); + return ((c = memrchr(str, '[', len)) && sscanf(c, "[%p]", p)); #else /* tested FreeBSD */ return ((c = strstr(str, "0x")) && sscanf(c, "%p", p)); #endif -- cgit v1.2.3-24-ge0c7