aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-12-31 23:41:06 +0000
committerUlrich Drepper <drepper@redhat.com>2003-12-31 23:41:06 +0000
commitc49e3d227e4692c90c8e7d674388bafd9c2ecfe8 (patch)
treededc37667d259d8361f1a53752d8ae7b9890a432
parente039fb25f0ce5dc8e605ee0de245fd3cd84f5025 (diff)
downloadglibc-c49e3d227e4692c90c8e7d674388bafd9c2ecfe8.tar
glibc-c49e3d227e4692c90c8e7d674388bafd9c2ecfe8.tar.gz
glibc-c49e3d227e4692c90c8e7d674388bafd9c2ecfe8.tar.bz2
glibc-c49e3d227e4692c90c8e7d674388bafd9c2ecfe8.zip
(pthread_getattr_np): Make sure stack info returned for main thread does not overlap with any other VMA.
-rw-r--r--nptl/pthread_getattr_np.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/nptl/pthread_getattr_np.c b/nptl/pthread_getattr_np.c
index f66e97fa68..0e1082079a 100644
--- a/nptl/pthread_getattr_np.c
+++ b/nptl/pthread_getattr_np.c
@@ -98,6 +98,7 @@ pthread_getattr_np (thread_id, attr)
char *line = NULL;
size_t linelen = 0;
+ uintptr_t last_to = 0;
while (! feof_unlocked (fp))
{
@@ -106,23 +107,25 @@ pthread_getattr_np (thread_id, attr)
uintptr_t from;
uintptr_t to;
- if (sscanf (line, "%" SCNxPTR "-%" SCNxPTR, &from, &to) == 2
- && from <= (uintptr_t) __libc_stack_end
+ if (sscanf (line, "%" SCNxPTR "-%" SCNxPTR, &from, &to) != 2)
+ continue;
+ if (from <= (uintptr_t) __libc_stack_end
&& (uintptr_t) __libc_stack_end < to)
{
/* Found the entry. Now we have the info we need. */
iattr->stacksize = rl.rlim_cur;
iattr->stackaddr = (void *) to;
- /* The limit might be too high. This is a bogus
- situation but try to avoid making it worse. */
- if ((size_t) iattr->stacksize > (size_t) iattr->stackaddr)
- iattr->stacksize = (size_t) iattr->stackaddr;
+ /* The limit might be too high. */
+ if ((size_t) iattr->stacksize
+ > (size_t) iattr->stackaddr - last_to)
+ iattr->stacksize = (size_t) iattr->stackaddr - last_to;
/* We succeed and no need to look further. */
ret = 0;
break;
}
+ last_to = to;
}
fclose (fp);