diff options
Diffstat (limited to 'nptl/pthread_getattr_np.c')
-rw-r--r-- | nptl/pthread_getattr_np.c | 15 |
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); |