mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-12 16:20:06 +00:00
(pthread_getattr_np): Make sure stack info returned for main thread does not overlap with any other VMA.
This commit is contained in:
parent
e039fb25f0
commit
c49e3d227e
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user