1 |
commit: 98db340d61a9607ab179a5d4dc057cf453d90e55 |
2 |
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Sep 15 18:21:29 2015 +0000 |
4 |
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Sep 15 18:21:29 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=98db340d |
7 |
|
8 |
libsandbox: avoid leaking memory when extracting strings |
9 |
|
10 |
If userland supports process_vm_readv, but the kernel does not (newer |
11 |
kernel headers & C lib than kernel), then we leak a bit of memory when |
12 |
we fallback to the ptrace code. Do not re-allocate the ret buffer if |
13 |
the code does fallback. |
14 |
|
15 |
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org> |
16 |
|
17 |
libsandbox/trace.c | 5 +++-- |
18 |
1 file changed, 3 insertions(+), 2 deletions(-) |
19 |
|
20 |
diff --git a/libsandbox/trace.c b/libsandbox/trace.c |
21 |
index dfbab18..1d40392 100644 |
22 |
--- a/libsandbox/trace.c |
23 |
+++ b/libsandbox/trace.c |
24 |
@@ -119,11 +119,12 @@ static char *do_peekstr(unsigned long lptr) |
25 |
ret = xrealloc(ret, len); |
26 |
liov.iov_base = ret + len - l; |
27 |
} |
28 |
+#else |
29 |
+ len = 1024; |
30 |
+ ret = xmalloc(len); |
31 |
#endif |
32 |
|
33 |
l = 0; |
34 |
- len = 1024; |
35 |
- ret = xmalloc(len); |
36 |
while (1) { |
37 |
a = lptr & (sizeof(long) - 1); |
38 |
lptr -= a; |