diff options
author | Ulrich Drepper <drepper@redhat.com> | 2001-04-11 21:29:54 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2001-04-11 21:29:54 +0000 |
commit | 95fe9d959f956c8b31a3bd8801ea9dfe475842a5 (patch) | |
tree | f12d85c19d5e186d8771e586d192b030efe0a641 | |
parent | 8ee355155102ad7c2e473f179f4879c6e468f19e (diff) | |
download | glibc-95fe9d959f956c8b31a3bd8801ea9dfe475842a5.tar glibc-95fe9d959f956c8b31a3bd8801ea9dfe475842a5.tar.gz glibc-95fe9d959f956c8b31a3bd8801ea9dfe475842a5.tar.bz2 glibc-95fe9d959f956c8b31a3bd8801ea9dfe475842a5.zip |
Update.
2001-04-11 Ulrich Drepper <drepper@redhat.com>
* cancel.c (_pthread_cleanup_push): Catch invalid __prev buffer
and remove it.
(_pthread_cleanup_push_defer): Likewise.
* tst-cancel.c (main): Fix loop printing cleanup output.
-rw-r--r-- | linuxthreads/ChangeLog | 8 | ||||
-rw-r--r-- | linuxthreads/cancel.c | 24 | ||||
-rw-r--r-- | linuxthreads/tst-cancel.c | 2 |
3 files changed, 31 insertions, 3 deletions
diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog index 805e837af5..47c15c65cb 100644 --- a/linuxthreads/ChangeLog +++ b/linuxthreads/ChangeLog @@ -1,3 +1,11 @@ +2001-04-11 Ulrich Drepper <drepper@redhat.com> + + * cancel.c (_pthread_cleanup_push): Catch invalid __prev buffer + and remove it. + (_pthread_cleanup_push_defer): Likewise. + + * tst-cancel.c (main): Fix loop printing cleanup output. + 2001-04-10 kaz Kojima <kkojima@rr.iij4u.or.jp> * sysdeps/sh/pspinlock.c (__pthread_spin_lock): Fix a reverse diff --git a/linuxthreads/cancel.c b/linuxthreads/cancel.c index ed67a6845f..32ad17c838 100644 --- a/linuxthreads/cancel.c +++ b/linuxthreads/cancel.c @@ -125,6 +125,18 @@ void _pthread_cleanup_push(struct _pthread_cleanup_buffer * buffer, buffer->__routine = routine; buffer->__arg = arg; buffer->__prev = THREAD_GETMEM(self, p_cleanup); + if (buffer->__prev != NULL) + { +#if _STACK_GROWS_DOWN + if ((char *) buffer >= (char *) buffer->__prev) + buffer->__prev = NULL; +#elif _STACK_GROWS_UP + if ((char *) buffer <= (char *) buffer->__prev) + buffer->__prev = NULL; +#else +# error "Define either _STACK_GROWS_DOWN or _STACK_GROWS_UP" +#endif + } THREAD_SETMEM(self, p_cleanup, buffer); } @@ -144,6 +156,16 @@ void _pthread_cleanup_push_defer(struct _pthread_cleanup_buffer * buffer, buffer->__arg = arg; buffer->__canceltype = THREAD_GETMEM(self, p_canceltype); buffer->__prev = THREAD_GETMEM(self, p_cleanup); + if (buffer->__prev != NULL) + { +#if _STACK_GROWS_DOWN + if ((char *) buffer >= (char *) buffer->__prev) + buffer->__prev = NULL; +#elif _STACK_GROWS_UP + if ((char *) buffer <= (char *) buffer->__prev) + buffer->__prev = NULL; +#endif + } THREAD_SETMEM(self, p_canceltype, PTHREAD_CANCEL_DEFERRED); THREAD_SETMEM(self, p_cleanup, buffer); } @@ -174,8 +196,6 @@ void __pthread_perform_cleanup(char *currentframe) #elif _STACK_GROWS_UP if ((char *) c >= currentframe) break; -#else -# error "Define either _STACK_GROWS_DOWN or _STACK_GROWS_UP" #endif c->__routine(c->__arg); } diff --git a/linuxthreads/tst-cancel.c b/linuxthreads/tst-cancel.c index da70d1278f..75d6c0de66 100644 --- a/linuxthreads/tst-cancel.c +++ b/linuxthreads/tst-cancel.c @@ -142,7 +142,7 @@ main (void) while (1) { ssize_t n = read (fd, buf, sizeof buf); - if (n < 0) + if (n <= 0) break; write (STDOUT_FILENO, buf, n); } |