This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hi! On systems with more than 32 * 8 CPUs pthread_getattr_np would get into an endless loop. Furthermore, if realloc fails, we certainly shouldn't dereference NULL pointer, but break out of the loop (free (cpuset) is done after the loop on failures). The other change is just trying to avoid buffer overflows on systems with more than 16 billion CPUs (res is a signed value, so if kernel returned non-error, but bigger than INT_MAX, the following memcpy would do the wrong thing on 64-bit arches (clear some area beyond end of buffer)). 2004-03-22 Jakub Jelinek <jakub@redhat.com> * sysdeps/unix/sysv/linux/pthread_getaffinity.c (__pthread_getaffinity_new): Use INT_MAX instead of UINT_MAX. * pthread_getattr_np.c (pthread_getattr_np): Double size every cycle. If realloc fails, break out of the loop. --- libc/nptl/sysdeps/unix/sysv/linux/pthread_getaffinity.c.jj 2004-03-22 14:45:57.000000000 +0100 +++ libc/nptl/sysdeps/unix/sysv/linux/pthread_getaffinity.c 2004-03-22 15:18:42.402868578 +0100 @@ -34,7 +34,7 @@ __pthread_getaffinity_new (pthread_t th, INTERNAL_SYSCALL_DECL (err); int res = INTERNAL_SYSCALL (sched_getaffinity, err, 3, pd->tid, - MIN (UINT_MAX, cpusetsize), cpuset); + MIN (INT_MAX, cpusetsize), cpuset); if (INTERNAL_SYSCALL_ERROR_P (res, err)) return INTERNAL_SYSCALL_ERRNO (res, err); --- libc/nptl/pthread_getattr_np.c.jj 2004-03-22 14:42:35.000000000 +0100 +++ libc/nptl/pthread_getattr_np.c 2004-03-22 15:11:39.416215690 +0100 @@ -135,16 +135,18 @@ pthread_getattr_np (thread_id, attr) if (ret == 0) { - size_t size = 32; + size_t size = 16; cpu_set_t *cpuset = NULL; do { + size <<= 1; + void *newp = realloc (cpuset, size); if (newp == NULL) { - free (cpuset); ret = ENOMEM; + break; } cpuset = (cpu_set_t *) newp; Jakub
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |