diff options
Diffstat (limited to 'crypto/err')
-rw-r--r-- | crypto/err/err.c | 28 | ||||
-rw-r--r-- | crypto/err/err.h | 54 |
2 files changed, 74 insertions, 8 deletions
diff --git a/crypto/err/err.c b/crypto/err/err.c index 3367a75d99..6812a9afed 100644 --- a/crypto/err/err.c +++ b/crypto/err/err.c @@ -56,7 +56,7 @@ * [including the GNU Public Licence.] */ /* ==================================================================== - * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. + * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -973,24 +973,32 @@ static int err_cmp(const void *a_void, const void *b_void) /* static unsigned long pid_hash(ERR_STATE *a) */ static unsigned long pid_hash(const void *a_void) { - return(((const ERR_STATE *)a_void)->pid*13); + return((((const ERR_STATE *)a_void)->pid + (unsigned long)((const ERR_STATE *)a_void)->pidptr)*13); } /* static int pid_cmp(ERR_STATE *a, ERR_STATE *b) */ static int pid_cmp(const void *a_void, const void *b_void) { - return((int)((long)((const ERR_STATE *)a_void)->pid - - (long)((const ERR_STATE *)b_void)->pid)); + return (((const ERR_STATE *)a_void)->pid != ((const ERR_STATE *)b_void)->pid) + || (((const ERR_STATE *)a_void)->pidptr != ((const ERR_STATE *)b_void)->pidptr); } void ERR_remove_state(unsigned long pid) { ERR_STATE tmp; + void *pidptr; err_fns_check(); - if (pid == 0) - pid=(unsigned long)CRYPTO_thread_id(); + if (pid != 0) + pidptr = &errno; + else + { + pid = CRYPTO_thread_id(); + pidptr = CRYPTO_thread_idptr(); + } + tmp.pid=pid; + tmp.pidptr=pidptr; /* thread_del_item automatically destroys the LHASH if the number of * items reaches zero. */ ERRFN(thread_del_item)(&tmp); @@ -1002,10 +1010,13 @@ ERR_STATE *ERR_get_state(void) ERR_STATE *ret,tmp,*tmpp=NULL; int i; unsigned long pid; + void *pidptr; err_fns_check(); - pid=(unsigned long)CRYPTO_thread_id(); - tmp.pid=pid; + pid = CRYPTO_thread_id(); + pidptr = CRYPTO_thread_idptr(); + tmp.pid = pid; + tmp.pidptr = pidptr; ret=ERRFN(thread_get_item)(&tmp); /* ret == the error state, if NULL, make a new one */ @@ -1014,6 +1025,7 @@ ERR_STATE *ERR_get_state(void) ret=(ERR_STATE *)OPENSSL_malloc(sizeof(ERR_STATE)); if (ret == NULL) return(&fallback); ret->pid=pid; + ret->pidptr=pidptr; ret->top=0; ret->bottom=0; for (i=0; i<ERR_NUM_ERRORS; i++) diff --git a/crypto/err/err.h b/crypto/err/err.h index e0e808bd36..3e3d395f3b 100644 --- a/crypto/err/err.h +++ b/crypto/err/err.h @@ -55,6 +55,59 @@ * copied and put under another distribution licence * [including the GNU Public Licence.] */ +/* ==================================================================== + * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ #ifndef HEADER_ERR_H #define HEADER_ERR_H @@ -95,6 +148,7 @@ extern "C" { typedef struct err_state_st { unsigned long pid; + void *pidptr; /* new in OpenSSL 0.9.9 */ int err_flags[ERR_NUM_ERRORS]; unsigned long err_buffer[ERR_NUM_ERRORS]; char *err_data[ERR_NUM_ERRORS]; |