diff options
author | Mike Frysinger <vapier@gentoo.org> | 2015-09-15 14:21:29 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2015-09-15 14:21:29 -0400 |
commit | 98db340d61a9607ab179a5d4dc057cf453d90e55 (patch) | |
tree | 0d8d2c35f89fd3a92236c4d4b1c6a801aa6b33db /libsandbox/trace.c | |
parent | update autotool files (diff) | |
download | sandbox-98db340d61a9607ab179a5d4dc057cf453d90e55.tar.gz sandbox-98db340d61a9607ab179a5d4dc057cf453d90e55.tar.bz2 sandbox-98db340d61a9607ab179a5d4dc057cf453d90e55.zip |
libsandbox: avoid leaking memory when extracting strings
If userland supports process_vm_readv, but the kernel does not (newer
kernel headers & C lib than kernel), then we leak a bit of memory when
we fallback to the ptrace code. Do not re-allocate the ret buffer if
the code does fallback.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'libsandbox/trace.c')
-rw-r--r-- | libsandbox/trace.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/libsandbox/trace.c b/libsandbox/trace.c index dfbab18..1d40392 100644 --- a/libsandbox/trace.c +++ b/libsandbox/trace.c @@ -119,11 +119,12 @@ static char *do_peekstr(unsigned long lptr) ret = xrealloc(ret, len); liov.iov_base = ret + len - l; } +#else + len = 1024; + ret = xmalloc(len); #endif l = 0; - len = 1024; - ret = xmalloc(len); while (1) { a = lptr & (sizeof(long) - 1); lptr -= a; |