diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/err/err.c | 1002 | ||||
| -rw-r--r-- | src/lib/libcrypto/err/err.h | 56 | ||||
| -rw-r--r-- | src/lib/libcrypto/err/err_all.c | 21 | ||||
| -rw-r--r-- | src/lib/libcrypto/err/err_prn.c | 70 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/err/err.c | 1002 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/err/err.h | 56 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/err/err_all.c | 21 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/err/err_prn.c | 70 |
8 files changed, 1182 insertions, 1116 deletions
diff --git a/src/lib/libcrypto/err/err.c b/src/lib/libcrypto/err/err.c index c44a065486..eaafb29101 100644 --- a/src/lib/libcrypto/err/err.c +++ b/src/lib/libcrypto/err/err.c | |||
| @@ -5,21 +5,21 @@ | |||
| 5 | * This package is an SSL implementation written | 5 | * This package is an SSL implementation written |
| 6 | * by Eric Young (eay@cryptsoft.com). | 6 | * by Eric Young (eay@cryptsoft.com). |
| 7 | * The implementation was written so as to conform with Netscapes SSL. | 7 | * The implementation was written so as to conform with Netscapes SSL. |
| 8 | * | 8 | * |
| 9 | * This library is free for commercial and non-commercial use as long as | 9 | * This library is free for commercial and non-commercial use as long as |
| 10 | * the following conditions are aheared to. The following conditions | 10 | * the following conditions are aheared to. The following conditions |
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | 11 | * apply to all code found in this distribution, be it the RC4, RSA, |
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation |
| 13 | * included with this distribution is covered by the same copyright terms | 13 | * included with this distribution is covered by the same copyright terms |
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
| 15 | * | 15 | * |
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | 16 | * Copyright remains Eric Young's, and as such any Copyright notices in |
| 17 | * the code are not to be removed. | 17 | * the code are not to be removed. |
| 18 | * If this package is used in a product, Eric Young should be given attribution | 18 | * If this package is used in a product, Eric Young should be given attribution |
| 19 | * as the author of the parts of the library used. | 19 | * as the author of the parts of the library used. |
| 20 | * This can be in the form of a textual message at program startup or | 20 | * This can be in the form of a textual message at program startup or |
| 21 | * in documentation (online or textual) provided with the package. | 21 | * in documentation (online or textual) provided with the package. |
| 22 | * | 22 | * |
| 23 | * Redistribution and use in source and binary forms, with or without | 23 | * Redistribution and use in source and binary forms, with or without |
| 24 | * modification, are permitted provided that the following conditions | 24 | * modification, are permitted provided that the following conditions |
| 25 | * are met: | 25 | * are met: |
| @@ -34,10 +34,10 @@ | |||
| 34 | * Eric Young (eay@cryptsoft.com)" | 34 | * Eric Young (eay@cryptsoft.com)" |
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | 35 | * The word 'cryptographic' can be left out if the rouines from the library |
| 36 | * being used are not cryptographic related :-). | 36 | * being used are not cryptographic related :-). |
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | 37 | * 4. If you include any Windows specific code (or a derivative thereof) from |
| 38 | * the apps directory (application code) you must include an acknowledgement: | 38 | * the apps directory (application code) you must include an acknowledgement: |
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
| 40 | * | 40 | * |
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| @@ -49,7 +49,7 @@ | |||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. |
| 52 | * | 52 | * |
| 53 | * The licence and distribution terms for any publically available version or | 53 | * The licence and distribution terms for any publically available version or |
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
| 55 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
| @@ -63,7 +63,7 @@ | |||
| 63 | * are met: | 63 | * are met: |
| 64 | * | 64 | * |
| 65 | * 1. Redistributions of source code must retain the above copyright | 65 | * 1. Redistributions of source code must retain the above copyright |
| 66 | * notice, this list of conditions and the following disclaimer. | 66 | * notice, this list of conditions and the following disclaimer. |
| 67 | * | 67 | * |
| 68 | * 2. Redistributions in binary form must reproduce the above copyright | 68 | * 2. Redistributions in binary form must reproduce the above copyright |
| 69 | * notice, this list of conditions and the following disclaimer in | 69 | * notice, this list of conditions and the following disclaimer in |
| @@ -126,106 +126,102 @@ static void err_load_strings(int lib, ERR_STRING_DATA *str); | |||
| 126 | 126 | ||
| 127 | static void ERR_STATE_free(ERR_STATE *s); | 127 | static void ERR_STATE_free(ERR_STATE *s); |
| 128 | #ifndef OPENSSL_NO_ERR | 128 | #ifndef OPENSSL_NO_ERR |
| 129 | static ERR_STRING_DATA ERR_str_libraries[]= | 129 | static ERR_STRING_DATA ERR_str_libraries[] = { |
| 130 | { | 130 | {ERR_PACK(ERR_LIB_NONE,0,0) , "unknown library"}, |
| 131 | {ERR_PACK(ERR_LIB_NONE,0,0) ,"unknown library"}, | 131 | {ERR_PACK(ERR_LIB_SYS,0,0) , "system library"}, |
| 132 | {ERR_PACK(ERR_LIB_SYS,0,0) ,"system library"}, | 132 | {ERR_PACK(ERR_LIB_BN,0,0) , "bignum routines"}, |
| 133 | {ERR_PACK(ERR_LIB_BN,0,0) ,"bignum routines"}, | 133 | {ERR_PACK(ERR_LIB_RSA,0,0) , "rsa routines"}, |
| 134 | {ERR_PACK(ERR_LIB_RSA,0,0) ,"rsa routines"}, | 134 | {ERR_PACK(ERR_LIB_DH,0,0) , "Diffie-Hellman routines"}, |
| 135 | {ERR_PACK(ERR_LIB_DH,0,0) ,"Diffie-Hellman routines"}, | 135 | {ERR_PACK(ERR_LIB_EVP,0,0) , "digital envelope routines"}, |
| 136 | {ERR_PACK(ERR_LIB_EVP,0,0) ,"digital envelope routines"}, | 136 | {ERR_PACK(ERR_LIB_BUF,0,0) , "memory buffer routines"}, |
| 137 | {ERR_PACK(ERR_LIB_BUF,0,0) ,"memory buffer routines"}, | 137 | {ERR_PACK(ERR_LIB_OBJ,0,0) , "object identifier routines"}, |
| 138 | {ERR_PACK(ERR_LIB_OBJ,0,0) ,"object identifier routines"}, | 138 | {ERR_PACK(ERR_LIB_PEM,0,0) , "PEM routines"}, |
| 139 | {ERR_PACK(ERR_LIB_PEM,0,0) ,"PEM routines"}, | 139 | {ERR_PACK(ERR_LIB_DSA,0,0) , "dsa routines"}, |
| 140 | {ERR_PACK(ERR_LIB_DSA,0,0) ,"dsa routines"}, | 140 | {ERR_PACK(ERR_LIB_X509,0,0) , "x509 certificate routines"}, |
| 141 | {ERR_PACK(ERR_LIB_X509,0,0) ,"x509 certificate routines"}, | 141 | {ERR_PACK(ERR_LIB_ASN1,0,0) , "asn1 encoding routines"}, |
| 142 | {ERR_PACK(ERR_LIB_ASN1,0,0) ,"asn1 encoding routines"}, | 142 | {ERR_PACK(ERR_LIB_CONF,0,0) , "configuration file routines"}, |
| 143 | {ERR_PACK(ERR_LIB_CONF,0,0) ,"configuration file routines"}, | 143 | {ERR_PACK(ERR_LIB_CRYPTO,0,0) , "common libcrypto routines"}, |
| 144 | {ERR_PACK(ERR_LIB_CRYPTO,0,0) ,"common libcrypto routines"}, | 144 | {ERR_PACK(ERR_LIB_EC,0,0) , "elliptic curve routines"}, |
| 145 | {ERR_PACK(ERR_LIB_EC,0,0) ,"elliptic curve routines"}, | 145 | {ERR_PACK(ERR_LIB_SSL,0,0) , "SSL routines"}, |
| 146 | {ERR_PACK(ERR_LIB_SSL,0,0) ,"SSL routines"}, | 146 | {ERR_PACK(ERR_LIB_BIO,0,0) , "BIO routines"}, |
| 147 | {ERR_PACK(ERR_LIB_BIO,0,0) ,"BIO routines"}, | 147 | {ERR_PACK(ERR_LIB_PKCS7,0,0) , "PKCS7 routines"}, |
| 148 | {ERR_PACK(ERR_LIB_PKCS7,0,0) ,"PKCS7 routines"}, | 148 | {ERR_PACK(ERR_LIB_X509V3,0,0) , "X509 V3 routines"}, |
| 149 | {ERR_PACK(ERR_LIB_X509V3,0,0) ,"X509 V3 routines"}, | 149 | {ERR_PACK(ERR_LIB_PKCS12,0,0) , "PKCS12 routines"}, |
| 150 | {ERR_PACK(ERR_LIB_PKCS12,0,0) ,"PKCS12 routines"}, | 150 | {ERR_PACK(ERR_LIB_RAND,0,0) , "random number generator"}, |
| 151 | {ERR_PACK(ERR_LIB_RAND,0,0) ,"random number generator"}, | 151 | {ERR_PACK(ERR_LIB_DSO,0,0) , "DSO support routines"}, |
| 152 | {ERR_PACK(ERR_LIB_DSO,0,0) ,"DSO support routines"}, | 152 | {ERR_PACK(ERR_LIB_TS,0,0) , "time stamp routines"}, |
| 153 | {ERR_PACK(ERR_LIB_TS,0,0) ,"time stamp routines"}, | 153 | {ERR_PACK(ERR_LIB_ENGINE,0,0) , "engine routines"}, |
| 154 | {ERR_PACK(ERR_LIB_ENGINE,0,0) ,"engine routines"}, | 154 | {ERR_PACK(ERR_LIB_OCSP,0,0) , "OCSP routines"}, |
| 155 | {ERR_PACK(ERR_LIB_OCSP,0,0) ,"OCSP routines"}, | 155 | {ERR_PACK(ERR_LIB_FIPS,0,0) , "FIPS routines"}, |
| 156 | {ERR_PACK(ERR_LIB_FIPS,0,0) ,"FIPS routines"}, | 156 | {ERR_PACK(ERR_LIB_CMS,0,0) , "CMS routines"}, |
| 157 | {ERR_PACK(ERR_LIB_CMS,0,0) ,"CMS routines"}, | 157 | {ERR_PACK(ERR_LIB_HMAC,0,0) , "HMAC routines"}, |
| 158 | {ERR_PACK(ERR_LIB_HMAC,0,0) ,"HMAC routines"}, | 158 | {0, NULL}, |
| 159 | {0,NULL}, | 159 | }; |
| 160 | }; | 160 | |
| 161 | 161 | static ERR_STRING_DATA ERR_str_functs[] = { | |
| 162 | static ERR_STRING_DATA ERR_str_functs[]= | 162 | {ERR_PACK(0,SYS_F_FOPEN, 0), "fopen"}, |
| 163 | { | 163 | {ERR_PACK(0,SYS_F_CONNECT, 0), "connect"}, |
| 164 | {ERR_PACK(0,SYS_F_FOPEN,0), "fopen"}, | 164 | {ERR_PACK(0,SYS_F_GETSERVBYNAME, 0), "getservbyname"}, |
| 165 | {ERR_PACK(0,SYS_F_CONNECT,0), "connect"}, | 165 | {ERR_PACK(0,SYS_F_SOCKET, 0), "socket"}, |
| 166 | {ERR_PACK(0,SYS_F_GETSERVBYNAME,0), "getservbyname"}, | 166 | {ERR_PACK(0,SYS_F_IOCTLSOCKET, 0), "ioctl"}, |
| 167 | {ERR_PACK(0,SYS_F_SOCKET,0), "socket"}, | 167 | {ERR_PACK(0,SYS_F_BIND, 0), "bind"}, |
| 168 | {ERR_PACK(0,SYS_F_IOCTLSOCKET,0), "ioctl"}, | 168 | {ERR_PACK(0,SYS_F_LISTEN, 0), "listen"}, |
| 169 | {ERR_PACK(0,SYS_F_BIND,0), "bind"}, | 169 | {ERR_PACK(0,SYS_F_ACCEPT, 0), "accept"}, |
| 170 | {ERR_PACK(0,SYS_F_LISTEN,0), "listen"}, | ||
| 171 | {ERR_PACK(0,SYS_F_ACCEPT,0), "accept"}, | ||
| 172 | #ifdef OPENSSL_SYS_WINDOWS | 170 | #ifdef OPENSSL_SYS_WINDOWS |
| 173 | {ERR_PACK(0,SYS_F_WSASTARTUP,0), "WSAstartup"}, | 171 | {ERR_PACK(0,SYS_F_WSASTARTUP, 0), "WSAstartup"}, |
| 174 | #endif | 172 | #endif |
| 175 | {ERR_PACK(0,SYS_F_OPENDIR,0), "opendir"}, | 173 | {ERR_PACK(0,SYS_F_OPENDIR, 0), "opendir"}, |
| 176 | {ERR_PACK(0,SYS_F_FREAD,0), "fread"}, | 174 | {ERR_PACK(0,SYS_F_FREAD, 0), "fread"}, |
| 177 | {0,NULL}, | 175 | {0, NULL}, |
| 178 | }; | 176 | }; |
| 179 | 177 | ||
| 180 | static ERR_STRING_DATA ERR_str_reasons[]= | 178 | static ERR_STRING_DATA ERR_str_reasons[] = { |
| 181 | { | 179 | {ERR_R_SYS_LIB , "system lib"}, |
| 182 | {ERR_R_SYS_LIB ,"system lib"}, | 180 | {ERR_R_BN_LIB , "BN lib"}, |
| 183 | {ERR_R_BN_LIB ,"BN lib"}, | 181 | {ERR_R_RSA_LIB , "RSA lib"}, |
| 184 | {ERR_R_RSA_LIB ,"RSA lib"}, | 182 | {ERR_R_DH_LIB , "DH lib"}, |
| 185 | {ERR_R_DH_LIB ,"DH lib"}, | 183 | {ERR_R_EVP_LIB , "EVP lib"}, |
| 186 | {ERR_R_EVP_LIB ,"EVP lib"}, | 184 | {ERR_R_BUF_LIB , "BUF lib"}, |
| 187 | {ERR_R_BUF_LIB ,"BUF lib"}, | 185 | {ERR_R_OBJ_LIB , "OBJ lib"}, |
| 188 | {ERR_R_OBJ_LIB ,"OBJ lib"}, | 186 | {ERR_R_PEM_LIB , "PEM lib"}, |
| 189 | {ERR_R_PEM_LIB ,"PEM lib"}, | 187 | {ERR_R_DSA_LIB , "DSA lib"}, |
| 190 | {ERR_R_DSA_LIB ,"DSA lib"}, | 188 | {ERR_R_X509_LIB , "X509 lib"}, |
| 191 | {ERR_R_X509_LIB ,"X509 lib"}, | 189 | {ERR_R_ASN1_LIB , "ASN1 lib"}, |
| 192 | {ERR_R_ASN1_LIB ,"ASN1 lib"}, | 190 | {ERR_R_CONF_LIB , "CONF lib"}, |
| 193 | {ERR_R_CONF_LIB ,"CONF lib"}, | 191 | {ERR_R_CRYPTO_LIB , "CRYPTO lib"}, |
| 194 | {ERR_R_CRYPTO_LIB ,"CRYPTO lib"}, | 192 | {ERR_R_EC_LIB , "EC lib"}, |
| 195 | {ERR_R_EC_LIB ,"EC lib"}, | 193 | {ERR_R_SSL_LIB , "SSL lib"}, |
| 196 | {ERR_R_SSL_LIB ,"SSL lib"}, | 194 | {ERR_R_BIO_LIB , "BIO lib"}, |
| 197 | {ERR_R_BIO_LIB ,"BIO lib"}, | 195 | {ERR_R_PKCS7_LIB , "PKCS7 lib"}, |
| 198 | {ERR_R_PKCS7_LIB ,"PKCS7 lib"}, | 196 | {ERR_R_X509V3_LIB , "X509V3 lib"}, |
| 199 | {ERR_R_X509V3_LIB ,"X509V3 lib"}, | 197 | {ERR_R_PKCS12_LIB , "PKCS12 lib"}, |
| 200 | {ERR_R_PKCS12_LIB ,"PKCS12 lib"}, | 198 | {ERR_R_RAND_LIB , "RAND lib"}, |
| 201 | {ERR_R_RAND_LIB ,"RAND lib"}, | 199 | {ERR_R_DSO_LIB , "DSO lib"}, |
| 202 | {ERR_R_DSO_LIB ,"DSO lib"}, | 200 | {ERR_R_ENGINE_LIB , "ENGINE lib"}, |
| 203 | {ERR_R_ENGINE_LIB ,"ENGINE lib"}, | 201 | {ERR_R_OCSP_LIB , "OCSP lib"}, |
| 204 | {ERR_R_OCSP_LIB ,"OCSP lib"}, | 202 | {ERR_R_TS_LIB , "TS lib"}, |
| 205 | {ERR_R_TS_LIB ,"TS lib"}, | 203 | |
| 206 | 204 | {ERR_R_NESTED_ASN1_ERROR , "nested asn1 error"}, | |
| 207 | {ERR_R_NESTED_ASN1_ERROR ,"nested asn1 error"}, | 205 | {ERR_R_BAD_ASN1_OBJECT_HEADER , "bad asn1 object header"}, |
| 208 | {ERR_R_BAD_ASN1_OBJECT_HEADER ,"bad asn1 object header"}, | 206 | {ERR_R_BAD_GET_ASN1_OBJECT_CALL , "bad get asn1 object call"}, |
| 209 | {ERR_R_BAD_GET_ASN1_OBJECT_CALL ,"bad get asn1 object call"}, | 207 | {ERR_R_EXPECTING_AN_ASN1_SEQUENCE , "expecting an asn1 sequence"}, |
| 210 | {ERR_R_EXPECTING_AN_ASN1_SEQUENCE ,"expecting an asn1 sequence"}, | 208 | {ERR_R_ASN1_LENGTH_MISMATCH , "asn1 length mismatch"}, |
| 211 | {ERR_R_ASN1_LENGTH_MISMATCH ,"asn1 length mismatch"}, | 209 | {ERR_R_MISSING_ASN1_EOS , "missing asn1 eos"}, |
| 212 | {ERR_R_MISSING_ASN1_EOS ,"missing asn1 eos"}, | 210 | |
| 213 | 211 | {ERR_R_FATAL , "fatal"}, | |
| 214 | {ERR_R_FATAL ,"fatal"}, | 212 | {ERR_R_MALLOC_FAILURE , "malloc failure"}, |
| 215 | {ERR_R_MALLOC_FAILURE ,"malloc failure"}, | 213 | {ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED , "called a function you should not call"}, |
| 216 | {ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED ,"called a function you should not call"}, | 214 | {ERR_R_PASSED_NULL_PARAMETER , "passed a null parameter"}, |
| 217 | {ERR_R_PASSED_NULL_PARAMETER ,"passed a null parameter"}, | 215 | {ERR_R_INTERNAL_ERROR , "internal error"}, |
| 218 | {ERR_R_INTERNAL_ERROR ,"internal error"}, | 216 | {ERR_R_DISABLED , "called a function that was disabled at compile-time"}, |
| 219 | {ERR_R_DISABLED ,"called a function that was disabled at compile-time"}, | 217 | |
| 220 | 218 | {0, NULL}, | |
| 221 | {0,NULL}, | 219 | }; |
| 222 | }; | ||
| 223 | #endif | 220 | #endif |
| 224 | 221 | ||
| 225 | 222 | ||
| 226 | /* Define the predeclared (but externally opaque) "ERR_FNS" type */ | 223 | /* Define the predeclared (but externally opaque) "ERR_FNS" type */ |
| 227 | struct st_ERR_FNS | 224 | struct st_ERR_FNS { |
| 228 | { | ||
| 229 | /* Works on the "error_hash" string table */ | 225 | /* Works on the "error_hash" string table */ |
| 230 | LHASH_OF(ERR_STRING_DATA) *(*cb_err_get)(int create); | 226 | LHASH_OF(ERR_STRING_DATA) *(*cb_err_get)(int create); |
| 231 | void (*cb_err_del)(void); | 227 | void (*cb_err_del)(void); |
| @@ -240,7 +236,7 @@ struct st_ERR_FNS | |||
| 240 | void (*cb_thread_del_item)(const ERR_STATE *); | 236 | void (*cb_thread_del_item)(const ERR_STATE *); |
| 241 | /* Returns the next available error "library" numbers */ | 237 | /* Returns the next available error "library" numbers */ |
| 242 | int (*cb_get_next_lib)(void); | 238 | int (*cb_get_next_lib)(void); |
| 243 | }; | 239 | }; |
| 244 | 240 | ||
| 245 | /* Predeclarations of the "err_defaults" functions */ | 241 | /* Predeclarations of the "err_defaults" functions */ |
| 246 | static LHASH_OF(ERR_STRING_DATA) *int_err_get(int create); | 242 | static LHASH_OF(ERR_STRING_DATA) *int_err_get(int create); |
| @@ -254,9 +250,9 @@ static ERR_STATE *int_thread_get_item(const ERR_STATE *); | |||
| 254 | static ERR_STATE *int_thread_set_item(ERR_STATE *); | 250 | static ERR_STATE *int_thread_set_item(ERR_STATE *); |
| 255 | static void int_thread_del_item(const ERR_STATE *); | 251 | static void int_thread_del_item(const ERR_STATE *); |
| 256 | static int int_err_get_next_lib(void); | 252 | static int int_err_get_next_lib(void); |
| 253 | |||
| 257 | /* The static ERR_FNS table using these defaults functions */ | 254 | /* The static ERR_FNS table using these defaults functions */ |
| 258 | static const ERR_FNS err_defaults = | 255 | static const ERR_FNS err_defaults = { |
| 259 | { | ||
| 260 | int_err_get, | 256 | int_err_get, |
| 261 | int_err_del, | 257 | int_err_del, |
| 262 | int_err_get_item, | 258 | int_err_get_item, |
| @@ -268,7 +264,7 @@ static const ERR_FNS err_defaults = | |||
| 268 | int_thread_set_item, | 264 | int_thread_set_item, |
| 269 | int_thread_del_item, | 265 | int_thread_del_item, |
| 270 | int_err_get_next_lib | 266 | int_err_get_next_lib |
| 271 | }; | 267 | }; |
| 272 | 268 | ||
| 273 | /* The replacable table of ERR_FNS functions we use at run-time */ | 269 | /* The replacable table of ERR_FNS functions we use at run-time */ |
| 274 | static const ERR_FNS *err_fns = NULL; | 270 | static const ERR_FNS *err_fns = NULL; |
| @@ -284,100 +280,105 @@ static const ERR_FNS *err_fns = NULL; | |||
| 284 | static LHASH_OF(ERR_STRING_DATA) *int_error_hash = NULL; | 280 | static LHASH_OF(ERR_STRING_DATA) *int_error_hash = NULL; |
| 285 | static LHASH_OF(ERR_STATE) *int_thread_hash = NULL; | 281 | static LHASH_OF(ERR_STATE) *int_thread_hash = NULL; |
| 286 | static int int_thread_hash_references = 0; | 282 | static int int_thread_hash_references = 0; |
| 287 | static int int_err_library_number= ERR_LIB_USER; | 283 | static int int_err_library_number = ERR_LIB_USER; |
| 288 | 284 | ||
| 289 | /* Internal function that checks whether "err_fns" is set and if not, sets it to | 285 | /* Internal function that checks whether "err_fns" is set and if not, sets it to |
| 290 | * the defaults. */ | 286 | * the defaults. */ |
| 291 | static void err_fns_check(void) | 287 | static void |
| 292 | { | 288 | err_fns_check(void) |
| 293 | if (err_fns) return; | 289 | { |
| 294 | 290 | if (err_fns) | |
| 291 | return; | ||
| 292 | |||
| 295 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | 293 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); |
| 296 | if (!err_fns) | 294 | if (!err_fns) |
| 297 | err_fns = &err_defaults; | 295 | err_fns = &err_defaults; |
| 298 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | 296 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); |
| 299 | } | 297 | } |
| 300 | 298 | ||
| 301 | /* API functions to get or set the underlying ERR functions. */ | 299 | /* API functions to get or set the underlying ERR functions. */ |
| 302 | 300 | ||
| 303 | const ERR_FNS *ERR_get_implementation(void) | 301 | const ERR_FNS * |
| 304 | { | 302 | ERR_get_implementation(void) |
| 303 | { | ||
| 305 | err_fns_check(); | 304 | err_fns_check(); |
| 306 | return err_fns; | 305 | return err_fns; |
| 307 | } | 306 | } |
| 308 | 307 | ||
| 309 | int ERR_set_implementation(const ERR_FNS *fns) | 308 | int |
| 310 | { | 309 | ERR_set_implementation(const ERR_FNS *fns) |
| 310 | { | ||
| 311 | int ret = 0; | 311 | int ret = 0; |
| 312 | 312 | ||
| 313 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | 313 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); |
| 314 | /* It's too late if 'err_fns' is non-NULL. BTW: not much point setting | 314 | /* It's too late if 'err_fns' is non-NULL. BTW: not much point setting |
| 315 | * an error is there?! */ | 315 | * an error is there?! */ |
| 316 | if (!err_fns) | 316 | if (!err_fns) { |
| 317 | { | ||
| 318 | err_fns = fns; | 317 | err_fns = fns; |
| 319 | ret = 1; | 318 | ret = 1; |
| 320 | } | 319 | } |
| 321 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | 320 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); |
| 322 | return ret; | 321 | return ret; |
| 323 | } | 322 | } |
| 324 | 323 | ||
| 325 | /* These are the callbacks provided to "lh_new()" when creating the LHASH tables | 324 | /* These are the callbacks provided to "lh_new()" when creating the LHASH tables |
| 326 | * internal to the "err_defaults" implementation. */ | 325 | * internal to the "err_defaults" implementation. */ |
| 327 | 326 | ||
| 328 | static unsigned long get_error_values(int inc,int top,const char **file,int *line, | 327 | static unsigned long get_error_values(int inc, int top, const char **file, |
| 329 | const char **data,int *flags); | 328 | int *line, const char **data, int *flags); |
| 330 | 329 | ||
| 331 | /* The internal functions used in the "err_defaults" implementation */ | 330 | /* The internal functions used in the "err_defaults" implementation */ |
| 332 | 331 | ||
| 333 | static unsigned long err_string_data_hash(const ERR_STRING_DATA *a) | 332 | static unsigned long |
| 334 | { | 333 | err_string_data_hash(const ERR_STRING_DATA *a) |
| 335 | unsigned long ret,l; | 334 | { |
| 335 | unsigned long ret, l; | ||
| 336 | 336 | ||
| 337 | l=a->error; | 337 | l = a->error; |
| 338 | ret=l^ERR_GET_LIB(l)^ERR_GET_FUNC(l); | 338 | ret = l^ERR_GET_LIB(l)^ERR_GET_FUNC(l); |
| 339 | return(ret^ret%19*13); | 339 | return (ret^ret % 19*13); |
| 340 | } | 340 | } |
| 341 | static IMPLEMENT_LHASH_HASH_FN(err_string_data, ERR_STRING_DATA) | 341 | static IMPLEMENT_LHASH_HASH_FN(err_string_data, ERR_STRING_DATA) |
| 342 | 342 | ||
| 343 | static int err_string_data_cmp(const ERR_STRING_DATA *a, | 343 | static int |
| 344 | const ERR_STRING_DATA *b) | 344 | err_string_data_cmp(const ERR_STRING_DATA *a, const ERR_STRING_DATA *b) |
| 345 | { | 345 | { |
| 346 | return (int)(a->error - b->error); | 346 | return (int)(a->error - b->error); |
| 347 | } | 347 | } |
| 348 | static IMPLEMENT_LHASH_COMP_FN(err_string_data, ERR_STRING_DATA) | 348 | static IMPLEMENT_LHASH_COMP_FN(err_string_data, ERR_STRING_DATA) |
| 349 | 349 | ||
| 350 | static LHASH_OF(ERR_STRING_DATA) *int_err_get(int create) | 350 | static |
| 351 | { | 351 | LHASH_OF(ERR_STRING_DATA) *int_err_get(int create) |
| 352 | { | ||
| 352 | LHASH_OF(ERR_STRING_DATA) *ret = NULL; | 353 | LHASH_OF(ERR_STRING_DATA) *ret = NULL; |
| 353 | 354 | ||
| 354 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | 355 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); |
| 355 | if (!int_error_hash && create) | 356 | if (!int_error_hash && create) { |
| 356 | { | ||
| 357 | CRYPTO_push_info("int_err_get (err.c)"); | 357 | CRYPTO_push_info("int_err_get (err.c)"); |
| 358 | int_error_hash = lh_ERR_STRING_DATA_new(); | 358 | int_error_hash = lh_ERR_STRING_DATA_new(); |
| 359 | CRYPTO_pop_info(); | 359 | CRYPTO_pop_info(); |
| 360 | } | 360 | } |
| 361 | if (int_error_hash) | 361 | if (int_error_hash) |
| 362 | ret = int_error_hash; | 362 | ret = int_error_hash; |
| 363 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | 363 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); |
| 364 | 364 | ||
| 365 | return ret; | 365 | return ret; |
| 366 | } | 366 | } |
| 367 | 367 | ||
| 368 | static void int_err_del(void) | 368 | static void |
| 369 | { | 369 | int_err_del(void) |
| 370 | { | ||
| 370 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | 371 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); |
| 371 | if (int_error_hash) | 372 | if (int_error_hash) { |
| 372 | { | ||
| 373 | lh_ERR_STRING_DATA_free(int_error_hash); | 373 | lh_ERR_STRING_DATA_free(int_error_hash); |
| 374 | int_error_hash = NULL; | 374 | int_error_hash = NULL; |
| 375 | } | ||
| 376 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | ||
| 377 | } | 375 | } |
| 376 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | ||
| 377 | } | ||
| 378 | 378 | ||
| 379 | static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *d) | 379 | static ERR_STRING_DATA * |
| 380 | { | 380 | int_err_get_item(const ERR_STRING_DATA *d) |
| 381 | { | ||
| 381 | ERR_STRING_DATA *p; | 382 | ERR_STRING_DATA *p; |
| 382 | LHASH_OF(ERR_STRING_DATA) *hash; | 383 | LHASH_OF(ERR_STRING_DATA) *hash; |
| 383 | 384 | ||
| @@ -391,10 +392,11 @@ static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *d) | |||
| 391 | CRYPTO_r_unlock(CRYPTO_LOCK_ERR); | 392 | CRYPTO_r_unlock(CRYPTO_LOCK_ERR); |
| 392 | 393 | ||
| 393 | return p; | 394 | return p; |
| 394 | } | 395 | } |
| 395 | 396 | ||
| 396 | static ERR_STRING_DATA *int_err_set_item(ERR_STRING_DATA *d) | 397 | static ERR_STRING_DATA * |
| 397 | { | 398 | int_err_set_item(ERR_STRING_DATA *d) |
| 399 | { | ||
| 398 | ERR_STRING_DATA *p; | 400 | ERR_STRING_DATA *p; |
| 399 | LHASH_OF(ERR_STRING_DATA) *hash; | 401 | LHASH_OF(ERR_STRING_DATA) *hash; |
| 400 | 402 | ||
| @@ -408,10 +410,11 @@ static ERR_STRING_DATA *int_err_set_item(ERR_STRING_DATA *d) | |||
| 408 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | 410 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); |
| 409 | 411 | ||
| 410 | return p; | 412 | return p; |
| 411 | } | 413 | } |
| 412 | 414 | ||
| 413 | static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *d) | 415 | static ERR_STRING_DATA * |
| 414 | { | 416 | int_err_del_item(ERR_STRING_DATA *d) |
| 417 | { | ||
| 415 | ERR_STRING_DATA *p; | 418 | ERR_STRING_DATA *p; |
| 416 | LHASH_OF(ERR_STRING_DATA) *hash; | 419 | LHASH_OF(ERR_STRING_DATA) *hash; |
| 417 | 420 | ||
| @@ -425,55 +428,59 @@ static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *d) | |||
| 425 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | 428 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); |
| 426 | 429 | ||
| 427 | return p; | 430 | return p; |
| 428 | } | 431 | } |
| 429 | 432 | ||
| 430 | static unsigned long err_state_hash(const ERR_STATE *a) | 433 | static unsigned long |
| 431 | { | 434 | err_state_hash(const ERR_STATE *a) |
| 435 | { | ||
| 432 | return CRYPTO_THREADID_hash(&a->tid) * 13; | 436 | return CRYPTO_THREADID_hash(&a->tid) * 13; |
| 433 | } | 437 | } |
| 434 | static IMPLEMENT_LHASH_HASH_FN(err_state, ERR_STATE) | 438 | static IMPLEMENT_LHASH_HASH_FN(err_state, ERR_STATE) |
| 435 | 439 | ||
| 436 | static int err_state_cmp(const ERR_STATE *a, const ERR_STATE *b) | 440 | static int |
| 437 | { | 441 | err_state_cmp(const ERR_STATE *a, const ERR_STATE *b) |
| 442 | { | ||
| 438 | return CRYPTO_THREADID_cmp(&a->tid, &b->tid); | 443 | return CRYPTO_THREADID_cmp(&a->tid, &b->tid); |
| 439 | } | 444 | } |
| 440 | static IMPLEMENT_LHASH_COMP_FN(err_state, ERR_STATE) | 445 | static IMPLEMENT_LHASH_COMP_FN(err_state, ERR_STATE) |
| 441 | 446 | ||
| 442 | static LHASH_OF(ERR_STATE) *int_thread_get(int create) | 447 | static |
| 443 | { | 448 | LHASH_OF(ERR_STATE) *int_thread_get(int create) |
| 449 | { | ||
| 444 | LHASH_OF(ERR_STATE) *ret = NULL; | 450 | LHASH_OF(ERR_STATE) *ret = NULL; |
| 445 | 451 | ||
| 446 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | 452 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); |
| 447 | if (!int_thread_hash && create) | 453 | if (!int_thread_hash && create) { |
| 448 | { | ||
| 449 | CRYPTO_push_info("int_thread_get (err.c)"); | 454 | CRYPTO_push_info("int_thread_get (err.c)"); |
| 450 | int_thread_hash = lh_ERR_STATE_new(); | 455 | int_thread_hash = lh_ERR_STATE_new(); |
| 451 | CRYPTO_pop_info(); | 456 | CRYPTO_pop_info(); |
| 452 | } | 457 | } |
| 453 | if (int_thread_hash) | 458 | if (int_thread_hash) { |
| 454 | { | ||
| 455 | int_thread_hash_references++; | 459 | int_thread_hash_references++; |
| 456 | ret = int_thread_hash; | 460 | ret = int_thread_hash; |
| 457 | } | 461 | } |
| 458 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | 462 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); |
| 459 | return ret; | 463 | return ret; |
| 460 | } | 464 | } |
| 461 | 465 | ||
| 462 | static void int_thread_release(LHASH_OF(ERR_STATE) **hash) | 466 | static void |
| 463 | { | 467 | int_thread_release(LHASH_OF(ERR_STATE) **hash) |
| 468 | { | ||
| 464 | int i; | 469 | int i; |
| 465 | 470 | ||
| 466 | if (hash == NULL || *hash == NULL) | 471 | if (hash == NULL || *hash == NULL) |
| 467 | return; | 472 | return; |
| 468 | 473 | ||
| 469 | i = CRYPTO_add(&int_thread_hash_references, -1, CRYPTO_LOCK_ERR); | 474 | i = CRYPTO_add(&int_thread_hash_references, -1, CRYPTO_LOCK_ERR); |
| 470 | if (i > 0) return; | 475 | if (i > 0) |
| 476 | return; | ||
| 471 | 477 | ||
| 472 | *hash = NULL; | 478 | *hash = NULL; |
| 473 | } | 479 | } |
| 474 | 480 | ||
| 475 | static ERR_STATE *int_thread_get_item(const ERR_STATE *d) | 481 | static ERR_STATE * |
| 476 | { | 482 | int_thread_get_item(const ERR_STATE *d) |
| 483 | { | ||
| 477 | ERR_STATE *p; | 484 | ERR_STATE *p; |
| 478 | LHASH_OF(ERR_STATE) *hash; | 485 | LHASH_OF(ERR_STATE) *hash; |
| 479 | 486 | ||
| @@ -488,10 +495,11 @@ static ERR_STATE *int_thread_get_item(const ERR_STATE *d) | |||
| 488 | 495 | ||
| 489 | ERRFN(thread_release)(&hash); | 496 | ERRFN(thread_release)(&hash); |
| 490 | return p; | 497 | return p; |
| 491 | } | 498 | } |
| 492 | 499 | ||
| 493 | static ERR_STATE *int_thread_set_item(ERR_STATE *d) | 500 | static ERR_STATE * |
| 494 | { | 501 | int_thread_set_item(ERR_STATE *d) |
| 502 | { | ||
| 495 | ERR_STATE *p; | 503 | ERR_STATE *p; |
| 496 | LHASH_OF(ERR_STATE) *hash; | 504 | LHASH_OF(ERR_STATE) *hash; |
| 497 | 505 | ||
| @@ -506,10 +514,11 @@ static ERR_STATE *int_thread_set_item(ERR_STATE *d) | |||
| 506 | 514 | ||
| 507 | ERRFN(thread_release)(&hash); | 515 | ERRFN(thread_release)(&hash); |
| 508 | return p; | 516 | return p; |
| 509 | } | 517 | } |
| 510 | 518 | ||
| 511 | static void int_thread_del_item(const ERR_STATE *d) | 519 | static void |
| 512 | { | 520 | int_thread_del_item(const ERR_STATE *d) |
| 521 | { | ||
| 513 | ERR_STATE *p; | 522 | ERR_STATE *p; |
| 514 | LHASH_OF(ERR_STATE) *hash; | 523 | LHASH_OF(ERR_STATE) *hash; |
| 515 | 524 | ||
| @@ -521,21 +530,21 @@ static void int_thread_del_item(const ERR_STATE *d) | |||
| 521 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | 530 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); |
| 522 | p = lh_ERR_STATE_delete(hash, d); | 531 | p = lh_ERR_STATE_delete(hash, d); |
| 523 | /* make sure we don't leak memory */ | 532 | /* make sure we don't leak memory */ |
| 524 | if (int_thread_hash_references == 1 | 533 | if (int_thread_hash_references == 1 && |
| 525 | && int_thread_hash && lh_ERR_STATE_num_items(int_thread_hash) == 0) | 534 | int_thread_hash && lh_ERR_STATE_num_items(int_thread_hash) == 0) { |
| 526 | { | ||
| 527 | lh_ERR_STATE_free(int_thread_hash); | 535 | lh_ERR_STATE_free(int_thread_hash); |
| 528 | int_thread_hash = NULL; | 536 | int_thread_hash = NULL; |
| 529 | } | 537 | } |
| 530 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | 538 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); |
| 531 | 539 | ||
| 532 | ERRFN(thread_release)(&hash); | 540 | ERRFN(thread_release)(&hash); |
| 533 | if (p) | 541 | if (p) |
| 534 | ERR_STATE_free(p); | 542 | ERR_STATE_free(p); |
| 535 | } | 543 | } |
| 536 | 544 | ||
| 537 | static int int_err_get_next_lib(void) | 545 | static int |
| 538 | { | 546 | int_err_get_next_lib(void) |
| 547 | { | ||
| 539 | int ret; | 548 | int ret; |
| 540 | 549 | ||
| 541 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | 550 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); |
| @@ -543,7 +552,7 @@ static int int_err_get_next_lib(void) | |||
| 543 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | 552 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); |
| 544 | 553 | ||
| 545 | return ret; | 554 | return ret; |
| 546 | } | 555 | } |
| 547 | 556 | ||
| 548 | 557 | ||
| 549 | #ifndef OPENSSL_NO_ERR | 558 | #ifndef OPENSSL_NO_ERR |
| @@ -560,54 +569,51 @@ static ERR_STRING_DATA SYS_str_reasons[NUM_SYS_STR_REASONS + 1]; | |||
| 560 | * will be returned for SYSerr(), which always gets an errno | 569 | * will be returned for SYSerr(), which always gets an errno |
| 561 | * value and never one of those 'standard' reason codes. */ | 570 | * value and never one of those 'standard' reason codes. */ |
| 562 | 571 | ||
| 563 | static void build_SYS_str_reasons(void) | 572 | static void |
| 564 | { | 573 | build_SYS_str_reasons(void) |
| 574 | { | ||
| 565 | /* malloc cannot be used here, use static storage instead */ | 575 | /* malloc cannot be used here, use static storage instead */ |
| 566 | static char strerror_tab[NUM_SYS_STR_REASONS][LEN_SYS_STR_REASON]; | 576 | static char strerror_tab[NUM_SYS_STR_REASONS][LEN_SYS_STR_REASON]; |
| 567 | int i; | 577 | int i; |
| 568 | static int init = 1; | 578 | static int init = 1; |
| 569 | 579 | ||
| 570 | CRYPTO_r_lock(CRYPTO_LOCK_ERR); | 580 | CRYPTO_r_lock(CRYPTO_LOCK_ERR); |
| 571 | if (!init) | 581 | if (!init) { |
| 572 | { | ||
| 573 | CRYPTO_r_unlock(CRYPTO_LOCK_ERR); | 582 | CRYPTO_r_unlock(CRYPTO_LOCK_ERR); |
| 574 | return; | 583 | return; |
| 575 | } | 584 | } |
| 576 | 585 | ||
| 577 | CRYPTO_r_unlock(CRYPTO_LOCK_ERR); | 586 | CRYPTO_r_unlock(CRYPTO_LOCK_ERR); |
| 578 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | 587 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); |
| 579 | if (!init) | 588 | if (!init) { |
| 580 | { | ||
| 581 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | 589 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); |
| 582 | return; | 590 | return; |
| 583 | } | 591 | } |
| 584 | 592 | ||
| 585 | for (i = 1; i <= NUM_SYS_STR_REASONS; i++) | 593 | for (i = 1; i <= NUM_SYS_STR_REASONS; i++) { |
| 586 | { | ||
| 587 | ERR_STRING_DATA *str = &SYS_str_reasons[i - 1]; | 594 | ERR_STRING_DATA *str = &SYS_str_reasons[i - 1]; |
| 588 | 595 | ||
| 589 | str->error = (unsigned long)i; | 596 | str->error = (unsigned long)i; |
| 590 | if (str->string == NULL) | 597 | if (str->string == NULL) { |
| 591 | { | 598 | char (*dest)[LEN_SYS_STR_REASON] = |
| 592 | char (*dest)[LEN_SYS_STR_REASON] = &(strerror_tab[i - 1]); | 599 | &(strerror_tab[i - 1]); |
| 593 | char *src = strerror(i); | 600 | char *src = strerror(i); |
| 594 | if (src != NULL) | 601 | if (src != NULL) { |
| 595 | { | ||
| 596 | strlcpy(*dest, src, sizeof *dest); | 602 | strlcpy(*dest, src, sizeof *dest); |
| 597 | str->string = *dest; | 603 | str->string = *dest; |
| 598 | } | ||
| 599 | } | 604 | } |
| 605 | } | ||
| 600 | if (str->string == NULL) | 606 | if (str->string == NULL) |
| 601 | str->string = "unknown"; | 607 | str->string = "unknown"; |
| 602 | } | 608 | } |
| 603 | 609 | ||
| 604 | /* Now we still have SYS_str_reasons[NUM_SYS_STR_REASONS] = {0, NULL}, | 610 | /* Now we still have SYS_str_reasons[NUM_SYS_STR_REASONS] = {0, NULL}, |
| 605 | * as required by ERR_load_strings. */ | 611 | * as required by ERR_load_strings. */ |
| 606 | 612 | ||
| 607 | init = 0; | 613 | init = 0; |
| 608 | 614 | ||
| 609 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | 615 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); |
| 610 | } | 616 | } |
| 611 | #endif | 617 | #endif |
| 612 | 618 | ||
| 613 | #define err_clear_data(p,i) \ | 619 | #define err_clear_data(p,i) \ |
| @@ -630,216 +636,232 @@ static void build_SYS_str_reasons(void) | |||
| 630 | (p)->err_line[i]= -1; \ | 636 | (p)->err_line[i]= -1; \ |
| 631 | } while(0) | 637 | } while(0) |
| 632 | 638 | ||
| 633 | static void ERR_STATE_free(ERR_STATE *s) | 639 | static void |
| 634 | { | 640 | ERR_STATE_free(ERR_STATE *s) |
| 641 | { | ||
| 635 | int i; | 642 | int i; |
| 636 | 643 | ||
| 637 | if (s == NULL) | 644 | if (s == NULL) |
| 638 | return; | 645 | return; |
| 639 | 646 | ||
| 640 | for (i=0; i<ERR_NUM_ERRORS; i++) | 647 | for (i = 0; i < ERR_NUM_ERRORS; i++) { |
| 641 | { | 648 | err_clear_data(s, i); |
| 642 | err_clear_data(s,i); | ||
| 643 | } | ||
| 644 | free(s); | ||
| 645 | } | 649 | } |
| 650 | free(s); | ||
| 651 | } | ||
| 646 | 652 | ||
| 647 | void ERR_load_ERR_strings(void) | 653 | void |
| 648 | { | 654 | ERR_load_ERR_strings(void) |
| 655 | { | ||
| 649 | err_fns_check(); | 656 | err_fns_check(); |
| 650 | #ifndef OPENSSL_NO_ERR | 657 | #ifndef OPENSSL_NO_ERR |
| 651 | err_load_strings(0,ERR_str_libraries); | 658 | err_load_strings(0, ERR_str_libraries); |
| 652 | err_load_strings(0,ERR_str_reasons); | 659 | err_load_strings(0, ERR_str_reasons); |
| 653 | err_load_strings(ERR_LIB_SYS,ERR_str_functs); | 660 | err_load_strings(ERR_LIB_SYS, ERR_str_functs); |
| 654 | build_SYS_str_reasons(); | 661 | build_SYS_str_reasons(); |
| 655 | err_load_strings(ERR_LIB_SYS,SYS_str_reasons); | 662 | err_load_strings(ERR_LIB_SYS, SYS_str_reasons); |
| 656 | #endif | 663 | #endif |
| 657 | } | 664 | } |
| 658 | 665 | ||
| 659 | static void err_load_strings(int lib, ERR_STRING_DATA *str) | 666 | static void |
| 660 | { | 667 | err_load_strings(int lib, ERR_STRING_DATA *str) |
| 661 | while (str->error) | 668 | { |
| 662 | { | 669 | while (str->error) { |
| 663 | if (lib) | 670 | if (lib) |
| 664 | str->error|=ERR_PACK(lib,0,0); | 671 | str->error |= ERR_PACK(lib, 0, 0); |
| 665 | ERRFN(err_set_item)(str); | 672 | ERRFN(err_set_item)(str); |
| 666 | str++; | 673 | str++; |
| 667 | } | ||
| 668 | } | 674 | } |
| 675 | } | ||
| 669 | 676 | ||
| 670 | void ERR_load_strings(int lib, ERR_STRING_DATA *str) | 677 | void |
| 671 | { | 678 | ERR_load_strings(int lib, ERR_STRING_DATA *str) |
| 679 | { | ||
| 672 | ERR_load_ERR_strings(); | 680 | ERR_load_ERR_strings(); |
| 673 | err_load_strings(lib, str); | 681 | err_load_strings(lib, str); |
| 674 | } | 682 | } |
| 675 | 683 | ||
| 676 | void ERR_unload_strings(int lib, ERR_STRING_DATA *str) | 684 | void |
| 677 | { | 685 | ERR_unload_strings(int lib, ERR_STRING_DATA *str) |
| 678 | while (str->error) | 686 | { |
| 679 | { | 687 | while (str->error) { |
| 680 | if (lib) | 688 | if (lib) |
| 681 | str->error|=ERR_PACK(lib,0,0); | 689 | str->error |= ERR_PACK(lib, 0, 0); |
| 682 | ERRFN(err_del_item)(str); | 690 | ERRFN(err_del_item)(str); |
| 683 | str++; | 691 | str++; |
| 684 | } | ||
| 685 | } | 692 | } |
| 693 | } | ||
| 686 | 694 | ||
| 687 | void ERR_free_strings(void) | 695 | void |
| 688 | { | 696 | ERR_free_strings(void) |
| 697 | { | ||
| 689 | err_fns_check(); | 698 | err_fns_check(); |
| 690 | ERRFN(err_del)(); | 699 | ERRFN(err_del)(); |
| 691 | } | 700 | } |
| 692 | 701 | ||
| 693 | /********************************************************/ | 702 | /********************************************************/ |
| 694 | 703 | ||
| 695 | void ERR_put_error(int lib, int func, int reason, const char *file, | 704 | void |
| 696 | int line) | 705 | ERR_put_error(int lib, int func, int reason, const char *file, int line) |
| 697 | { | 706 | { |
| 698 | ERR_STATE *es; | 707 | ERR_STATE *es; |
| 699 | 708 | ||
| 700 | es=ERR_get_state(); | 709 | es = ERR_get_state(); |
| 701 | 710 | ||
| 702 | es->top=(es->top+1)%ERR_NUM_ERRORS; | 711 | es->top = (es->top + 1) % ERR_NUM_ERRORS; |
| 703 | if (es->top == es->bottom) | 712 | if (es->top == es->bottom) |
| 704 | es->bottom=(es->bottom+1)%ERR_NUM_ERRORS; | 713 | es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS; |
| 705 | es->err_flags[es->top]=0; | 714 | es->err_flags[es->top] = 0; |
| 706 | es->err_buffer[es->top]=ERR_PACK(lib,func,reason); | 715 | es->err_buffer[es->top] = ERR_PACK(lib, func, reason); |
| 707 | es->err_file[es->top]=file; | 716 | es->err_file[es->top] = file; |
| 708 | es->err_line[es->top]=line; | 717 | es->err_line[es->top] = line; |
| 709 | err_clear_data(es,es->top); | 718 | err_clear_data(es, es->top); |
| 710 | } | 719 | } |
| 711 | 720 | ||
| 712 | void ERR_clear_error(void) | 721 | void |
| 713 | { | 722 | ERR_clear_error(void) |
| 723 | { | ||
| 714 | int i; | 724 | int i; |
| 715 | ERR_STATE *es; | 725 | ERR_STATE *es; |
| 716 | 726 | ||
| 717 | es=ERR_get_state(); | 727 | es = ERR_get_state(); |
| 718 | 728 | ||
| 719 | for (i=0; i<ERR_NUM_ERRORS; i++) | 729 | for (i = 0; i < ERR_NUM_ERRORS; i++) { |
| 720 | { | 730 | err_clear(es, i); |
| 721 | err_clear(es,i); | ||
| 722 | } | ||
| 723 | es->top=es->bottom=0; | ||
| 724 | } | 731 | } |
| 732 | es->top = es->bottom = 0; | ||
| 733 | } | ||
| 725 | 734 | ||
| 726 | 735 | ||
| 727 | unsigned long ERR_get_error(void) | 736 | unsigned long ERR_get_error(void) |
| 728 | { return(get_error_values(1,0,NULL,NULL,NULL,NULL)); } | 737 | { |
| 738 | return (get_error_values(1, 0,NULL, NULL, NULL, NULL)); | ||
| 739 | } | ||
| 729 | 740 | ||
| 730 | unsigned long ERR_get_error_line(const char **file, | 741 | unsigned long ERR_get_error_line(const char **file, int *line) |
| 731 | int *line) | 742 | { |
| 732 | { return(get_error_values(1,0,file,line,NULL,NULL)); } | 743 | return (get_error_values(1, 0,file, line, NULL, NULL)); |
| 744 | } | ||
| 733 | 745 | ||
| 734 | unsigned long ERR_get_error_line_data(const char **file, int *line, | 746 | unsigned long ERR_get_error_line_data(const char **file, int *line, |
| 735 | const char **data, int *flags) | 747 | const char **data, int *flags) |
| 736 | { return(get_error_values(1,0,file,line,data,flags)); } | 748 | { |
| 749 | return (get_error_values(1, 0,file, line, data, flags)); | ||
| 750 | } | ||
| 737 | 751 | ||
| 738 | 752 | ||
| 739 | unsigned long ERR_peek_error(void) | 753 | unsigned long ERR_peek_error(void) |
| 740 | { return(get_error_values(0,0,NULL,NULL,NULL,NULL)); } | 754 | { |
| 755 | return (get_error_values(0, 0,NULL, NULL, NULL, NULL)); | ||
| 756 | } | ||
| 741 | 757 | ||
| 742 | unsigned long ERR_peek_error_line(const char **file, int *line) | 758 | unsigned long ERR_peek_error_line(const char **file, int *line) |
| 743 | { return(get_error_values(0,0,file,line,NULL,NULL)); } | 759 | { |
| 760 | return (get_error_values(0, 0,file, line, NULL, NULL)); | ||
| 761 | } | ||
| 744 | 762 | ||
| 745 | unsigned long ERR_peek_error_line_data(const char **file, int *line, | 763 | unsigned long ERR_peek_error_line_data(const char **file, int *line, |
| 746 | const char **data, int *flags) | 764 | const char **data, int *flags) |
| 747 | { return(get_error_values(0,0,file,line,data,flags)); } | 765 | { |
| 748 | 766 | return (get_error_values(0, 0,file, line, data, flags)); | |
| 767 | } | ||
| 749 | 768 | ||
| 750 | unsigned long ERR_peek_last_error(void) | 769 | unsigned long ERR_peek_last_error(void) |
| 751 | { return(get_error_values(0,1,NULL,NULL,NULL,NULL)); } | 770 | { |
| 771 | return (get_error_values(0, 1,NULL, NULL, NULL, NULL)); | ||
| 772 | } | ||
| 752 | 773 | ||
| 753 | unsigned long ERR_peek_last_error_line(const char **file, int *line) | 774 | unsigned long ERR_peek_last_error_line(const char **file, int *line) |
| 754 | { return(get_error_values(0,1,file,line,NULL,NULL)); } | 775 | { |
| 776 | return (get_error_values(0, 1,file, line, NULL, NULL)); | ||
| 777 | } | ||
| 755 | 778 | ||
| 756 | unsigned long ERR_peek_last_error_line_data(const char **file, int *line, | 779 | unsigned long ERR_peek_last_error_line_data(const char **file, int *line, |
| 757 | const char **data, int *flags) | 780 | const char **data, int *flags) |
| 758 | { return(get_error_values(0,1,file,line,data,flags)); } | 781 | { |
| 759 | 782 | return (get_error_values(0, 1,file, line, data, flags)); | |
| 760 | 783 | } | |
| 761 | static unsigned long get_error_values(int inc, int top, const char **file, int *line, | 784 | |
| 762 | const char **data, int *flags) | 785 | static unsigned |
| 763 | { | 786 | long get_error_values(int inc, int top, const char **file, int *line, |
| 764 | int i=0; | 787 | const char **data, int *flags) |
| 788 | { | ||
| 789 | int i = 0; | ||
| 765 | ERR_STATE *es; | 790 | ERR_STATE *es; |
| 766 | unsigned long ret; | 791 | unsigned long ret; |
| 767 | 792 | ||
| 768 | es=ERR_get_state(); | 793 | es = ERR_get_state(); |
| 794 | |||
| 795 | if (inc && top) { | ||
| 796 | if (file) | ||
| 797 | *file = ""; | ||
| 798 | if (line) | ||
| 799 | *line = 0; | ||
| 800 | if (data) | ||
| 801 | *data = ""; | ||
| 802 | if (flags) | ||
| 803 | *flags = 0; | ||
| 769 | 804 | ||
| 770 | if (inc && top) | ||
| 771 | { | ||
| 772 | if (file) *file = ""; | ||
| 773 | if (line) *line = 0; | ||
| 774 | if (data) *data = ""; | ||
| 775 | if (flags) *flags = 0; | ||
| 776 | |||
| 777 | return ERR_R_INTERNAL_ERROR; | 805 | return ERR_R_INTERNAL_ERROR; |
| 778 | } | 806 | } |
| 779 | 807 | ||
| 780 | if (es->bottom == es->top) return 0; | 808 | if (es->bottom == es->top) |
| 809 | return 0; | ||
| 781 | if (top) | 810 | if (top) |
| 782 | i=es->top; /* last error */ | 811 | i = es->top; /* last error */ |
| 783 | else | 812 | else |
| 784 | i=(es->bottom+1)%ERR_NUM_ERRORS; /* first error */ | 813 | i = (es->bottom + 1) % ERR_NUM_ERRORS; /* first error */ |
| 785 | 814 | ||
| 786 | ret=es->err_buffer[i]; | 815 | ret = es->err_buffer[i]; |
| 787 | if (inc) | 816 | if (inc) { |
| 788 | { | 817 | es->bottom = i; |
| 789 | es->bottom=i; | 818 | es->err_buffer[i] = 0; |
| 790 | es->err_buffer[i]=0; | 819 | } |
| 791 | } | ||
| 792 | 820 | ||
| 793 | if ((file != NULL) && (line != NULL)) | 821 | if ((file != NULL) && (line != NULL)) { |
| 794 | { | 822 | if (es->err_file[i] == NULL) { |
| 795 | if (es->err_file[i] == NULL) | 823 | *file = "NA"; |
| 796 | { | 824 | if (line != NULL) |
| 797 | *file="NA"; | 825 | *line = 0; |
| 798 | if (line != NULL) *line=0; | 826 | } else { |
| 799 | } | 827 | *file = es->err_file[i]; |
| 800 | else | 828 | if (line != NULL) |
| 801 | { | 829 | *line = es->err_line[i]; |
| 802 | *file=es->err_file[i]; | ||
| 803 | if (line != NULL) *line=es->err_line[i]; | ||
| 804 | } | ||
| 805 | } | 830 | } |
| 831 | } | ||
| 806 | 832 | ||
| 807 | if (data == NULL) | 833 | if (data == NULL) { |
| 808 | { | 834 | if (inc) { |
| 809 | if (inc) | ||
| 810 | { | ||
| 811 | err_clear_data(es, i); | 835 | err_clear_data(es, i); |
| 812 | } | ||
| 813 | } | 836 | } |
| 814 | else | 837 | } else { |
| 815 | { | 838 | if (es->err_data[i] == NULL) { |
| 816 | if (es->err_data[i] == NULL) | 839 | *data = ""; |
| 817 | { | 840 | if (flags != NULL) |
| 818 | *data=""; | 841 | *flags = 0; |
| 819 | if (flags != NULL) *flags=0; | 842 | } else { |
| 820 | } | 843 | *data = es->err_data[i]; |
| 821 | else | 844 | if (flags != NULL) |
| 822 | { | 845 | *flags = es->err_data_flags[i]; |
| 823 | *data=es->err_data[i]; | ||
| 824 | if (flags != NULL) *flags=es->err_data_flags[i]; | ||
| 825 | } | ||
| 826 | } | 846 | } |
| 827 | return ret; | ||
| 828 | } | 847 | } |
| 848 | return ret; | ||
| 849 | } | ||
| 829 | 850 | ||
| 830 | void ERR_error_string_n(unsigned long e, char *buf, size_t len) | 851 | void |
| 831 | { | 852 | ERR_error_string_n(unsigned long e, char *buf, size_t len) |
| 853 | { | ||
| 832 | char lsbuf[30], fsbuf[30], rsbuf[30]; | 854 | char lsbuf[30], fsbuf[30], rsbuf[30]; |
| 833 | const char *ls,*fs,*rs; | 855 | const char *ls, *fs, *rs; |
| 834 | int l, f, r, ret; | 856 | int l, f, r, ret; |
| 835 | 857 | ||
| 836 | l=ERR_GET_LIB(e); | 858 | l = ERR_GET_LIB(e); |
| 837 | f=ERR_GET_FUNC(e); | 859 | f = ERR_GET_FUNC(e); |
| 838 | r=ERR_GET_REASON(e); | 860 | r = ERR_GET_REASON(e); |
| 839 | 861 | ||
| 840 | ls=ERR_lib_error_string(e); | 862 | ls = ERR_lib_error_string(e); |
| 841 | fs=ERR_func_error_string(e); | 863 | fs = ERR_func_error_string(e); |
| 842 | rs=ERR_reason_error_string(e); | 864 | rs = ERR_reason_error_string(e); |
| 843 | 865 | ||
| 844 | if (ls == NULL) { | 866 | if (ls == NULL) { |
| 845 | (void) snprintf(lsbuf, sizeof(lsbuf), "lib(%d)", l); | 867 | (void) snprintf(lsbuf, sizeof(lsbuf), "lib(%d)", l); |
| @@ -857,108 +879,112 @@ void ERR_error_string_n(unsigned long e, char *buf, size_t len) | |||
| 857 | ret = snprintf(buf, len, "error:%08lX:%s:%s:%s", e, ls, fs, rs); | 879 | ret = snprintf(buf, len, "error:%08lX:%s:%s:%s", e, ls, fs, rs); |
| 858 | if (ret == -1) | 880 | if (ret == -1) |
| 859 | return; /* can't happen, and can't do better if it does */ | 881 | return; /* can't happen, and can't do better if it does */ |
| 860 | if (ret >= len) | 882 | if (ret >= len) { |
| 861 | { | 883 | /* output may be truncated; make sure we always have 5 |
| 862 | /* output may be truncated; make sure we always have 5 | ||
| 863 | * colon-separated fields, i.e. 4 colons ... */ | 884 | * colon-separated fields, i.e. 4 colons ... */ |
| 864 | #define NUM_COLONS 4 | 885 | #define NUM_COLONS 4 |
| 865 | if (len > NUM_COLONS) /* ... if possible */ | 886 | if (len > NUM_COLONS) /* ... if possible */ |
| 866 | { | 887 | { |
| 867 | int i; | 888 | int i; |
| 868 | char *s = buf; | 889 | char *s = buf; |
| 869 | 890 | ||
| 870 | for (i = 0; i < NUM_COLONS; i++) | 891 | for (i = 0; i < NUM_COLONS; i++) { |
| 871 | { | ||
| 872 | char *colon = strchr(s, ':'); | 892 | char *colon = strchr(s, ':'); |
| 873 | if (colon == NULL || colon > &buf[len-1] - NUM_COLONS + i) | 893 | if (colon == NULL || |
| 874 | { | 894 | colon > &buf[len - 1] - NUM_COLONS + i) { |
| 875 | /* set colon no. i at last possible position | 895 | /* set colon no. i at last possible position |
| 876 | * (buf[len-1] is the terminating 0)*/ | 896 | * (buf[len-1] is the terminating 0)*/ |
| 877 | colon = &buf[len-1] - NUM_COLONS + i; | 897 | colon = &buf[len - 1] - NUM_COLONS + i; |
| 878 | *colon = ':'; | 898 | *colon = ':'; |
| 879 | } | ||
| 880 | s = colon + 1; | ||
| 881 | } | 899 | } |
| 900 | s = colon + 1; | ||
| 882 | } | 901 | } |
| 883 | } | 902 | } |
| 884 | } | 903 | } |
| 904 | } | ||
| 885 | 905 | ||
| 886 | /* BAD for multi-threading: uses a local buffer if ret == NULL */ | 906 | /* BAD for multi-threading: uses a local buffer if ret == NULL */ |
| 887 | /* ERR_error_string_n should be used instead for ret != NULL | 907 | /* ERR_error_string_n should be used instead for ret != NULL |
| 888 | * as ERR_error_string cannot know how large the buffer is */ | 908 | * as ERR_error_string cannot know how large the buffer is */ |
| 889 | char *ERR_error_string(unsigned long e, char *ret) | 909 | char * |
| 890 | { | 910 | ERR_error_string(unsigned long e, char *ret) |
| 911 | { | ||
| 891 | static char buf[256]; | 912 | static char buf[256]; |
| 892 | 913 | ||
| 893 | if (ret == NULL) ret=buf; | 914 | if (ret == NULL) |
| 915 | ret = buf; | ||
| 894 | ERR_error_string_n(e, ret, 256); | 916 | ERR_error_string_n(e, ret, 256); |
| 895 | 917 | ||
| 896 | return ret; | 918 | return ret; |
| 897 | } | 919 | } |
| 898 | 920 | ||
| 899 | LHASH_OF(ERR_STRING_DATA) *ERR_get_string_table(void) | 921 | LHASH_OF(ERR_STRING_DATA) *ERR_get_string_table(void) |
| 900 | { | 922 | { |
| 901 | err_fns_check(); | 923 | err_fns_check(); |
| 902 | return ERRFN(err_get)(0); | 924 | return ERRFN(err_get)(0); |
| 903 | } | 925 | } |
| 904 | 926 | ||
| 905 | LHASH_OF(ERR_STATE) *ERR_get_err_state_table(void) | 927 | LHASH_OF(ERR_STATE) *ERR_get_err_state_table(void) |
| 906 | { | 928 | { |
| 907 | err_fns_check(); | 929 | err_fns_check(); |
| 908 | return ERRFN(thread_get)(0); | 930 | return ERRFN(thread_get)(0); |
| 909 | } | 931 | } |
| 910 | 932 | ||
| 911 | void ERR_release_err_state_table(LHASH_OF(ERR_STATE) **hash) | 933 | void |
| 912 | { | 934 | ERR_release_err_state_table(LHASH_OF(ERR_STATE) **hash) |
| 935 | { | ||
| 913 | err_fns_check(); | 936 | err_fns_check(); |
| 914 | ERRFN(thread_release)(hash); | 937 | ERRFN(thread_release)(hash); |
| 915 | } | 938 | } |
| 916 | 939 | ||
| 917 | const char *ERR_lib_error_string(unsigned long e) | 940 | const char * |
| 918 | { | 941 | ERR_lib_error_string(unsigned long e) |
| 919 | ERR_STRING_DATA d,*p; | 942 | { |
| 943 | ERR_STRING_DATA d, *p; | ||
| 920 | unsigned long l; | 944 | unsigned long l; |
| 921 | 945 | ||
| 922 | err_fns_check(); | 946 | err_fns_check(); |
| 923 | l=ERR_GET_LIB(e); | 947 | l = ERR_GET_LIB(e); |
| 924 | d.error=ERR_PACK(l,0,0); | 948 | d.error = ERR_PACK(l, 0, 0); |
| 925 | p=ERRFN(err_get_item)(&d); | 949 | p = ERRFN(err_get_item)(&d); |
| 926 | return((p == NULL)?NULL:p->string); | 950 | return ((p == NULL) ? NULL : p->string); |
| 927 | } | 951 | } |
| 928 | 952 | ||
| 929 | const char *ERR_func_error_string(unsigned long e) | 953 | const char * |
| 930 | { | 954 | ERR_func_error_string(unsigned long e) |
| 931 | ERR_STRING_DATA d,*p; | 955 | { |
| 932 | unsigned long l,f; | 956 | ERR_STRING_DATA d, *p; |
| 957 | unsigned long l, f; | ||
| 933 | 958 | ||
| 934 | err_fns_check(); | 959 | err_fns_check(); |
| 935 | l=ERR_GET_LIB(e); | 960 | l = ERR_GET_LIB(e); |
| 936 | f=ERR_GET_FUNC(e); | 961 | f = ERR_GET_FUNC(e); |
| 937 | d.error=ERR_PACK(l,f,0); | 962 | d.error = ERR_PACK(l, f, 0); |
| 938 | p=ERRFN(err_get_item)(&d); | 963 | p = ERRFN(err_get_item)(&d); |
| 939 | return((p == NULL)?NULL:p->string); | 964 | return ((p == NULL) ? NULL : p->string); |
| 940 | } | 965 | } |
| 941 | 966 | ||
| 942 | const char *ERR_reason_error_string(unsigned long e) | 967 | const char * |
| 943 | { | 968 | ERR_reason_error_string(unsigned long e) |
| 944 | ERR_STRING_DATA d,*p=NULL; | 969 | { |
| 945 | unsigned long l,r; | 970 | ERR_STRING_DATA d, *p = NULL; |
| 971 | unsigned long l, r; | ||
| 946 | 972 | ||
| 947 | err_fns_check(); | 973 | err_fns_check(); |
| 948 | l=ERR_GET_LIB(e); | 974 | l = ERR_GET_LIB(e); |
| 949 | r=ERR_GET_REASON(e); | 975 | r = ERR_GET_REASON(e); |
| 950 | d.error=ERR_PACK(l,0,r); | 976 | d.error = ERR_PACK(l, 0, r); |
| 951 | p=ERRFN(err_get_item)(&d); | 977 | p = ERRFN(err_get_item)(&d); |
| 952 | if (!p) | 978 | if (!p) { |
| 953 | { | 979 | d.error = ERR_PACK(0, 0, r); |
| 954 | d.error=ERR_PACK(0,0,r); | 980 | p = ERRFN(err_get_item)(&d); |
| 955 | p=ERRFN(err_get_item)(&d); | ||
| 956 | } | ||
| 957 | return((p == NULL)?NULL:p->string); | ||
| 958 | } | 981 | } |
| 982 | return ((p == NULL) ? NULL : p->string); | ||
| 983 | } | ||
| 959 | 984 | ||
| 960 | void ERR_remove_thread_state(const CRYPTO_THREADID *id) | 985 | void |
| 961 | { | 986 | ERR_remove_thread_state(const CRYPTO_THREADID *id) |
| 987 | { | ||
| 962 | ERR_STATE tmp; | 988 | ERR_STATE tmp; |
| 963 | 989 | ||
| 964 | if (id) | 990 | if (id) |
| @@ -969,147 +995,151 @@ void ERR_remove_thread_state(const CRYPTO_THREADID *id) | |||
| 969 | /* thread_del_item automatically destroys the LHASH if the number of | 995 | /* thread_del_item automatically destroys the LHASH if the number of |
| 970 | * items reaches zero. */ | 996 | * items reaches zero. */ |
| 971 | ERRFN(thread_del_item)(&tmp); | 997 | ERRFN(thread_del_item)(&tmp); |
| 972 | } | 998 | } |
| 973 | 999 | ||
| 974 | #ifndef OPENSSL_NO_DEPRECATED | 1000 | #ifndef OPENSSL_NO_DEPRECATED |
| 975 | void ERR_remove_state(unsigned long pid) | 1001 | void |
| 976 | { | 1002 | ERR_remove_state(unsigned long pid) |
| 1003 | { | ||
| 977 | ERR_remove_thread_state(NULL); | 1004 | ERR_remove_thread_state(NULL); |
| 978 | } | 1005 | } |
| 979 | #endif | 1006 | #endif |
| 980 | 1007 | ||
| 981 | ERR_STATE *ERR_get_state(void) | 1008 | ERR_STATE * |
| 982 | { | 1009 | ERR_get_state(void) |
| 1010 | { | ||
| 983 | static ERR_STATE fallback; | 1011 | static ERR_STATE fallback; |
| 984 | ERR_STATE *ret,tmp,*tmpp=NULL; | 1012 | ERR_STATE *ret, tmp, *tmpp = NULL; |
| 985 | int i; | 1013 | int i; |
| 986 | CRYPTO_THREADID tid; | 1014 | CRYPTO_THREADID tid; |
| 987 | 1015 | ||
| 988 | err_fns_check(); | 1016 | err_fns_check(); |
| 989 | CRYPTO_THREADID_current(&tid); | 1017 | CRYPTO_THREADID_current(&tid); |
| 990 | CRYPTO_THREADID_cpy(&tmp.tid, &tid); | 1018 | CRYPTO_THREADID_cpy(&tmp.tid, &tid); |
| 991 | ret=ERRFN(thread_get_item)(&tmp); | 1019 | ret = ERRFN(thread_get_item)(&tmp); |
| 992 | 1020 | ||
| 993 | /* ret == the error state, if NULL, make a new one */ | 1021 | /* ret == the error state, if NULL, make a new one */ |
| 994 | if (ret == NULL) | 1022 | if (ret == NULL) { |
| 995 | { | 1023 | ret = (ERR_STATE *)malloc(sizeof(ERR_STATE)); |
| 996 | ret=(ERR_STATE *)malloc(sizeof(ERR_STATE)); | 1024 | if (ret == NULL) |
| 997 | if (ret == NULL) return(&fallback); | 1025 | return (&fallback); |
| 998 | CRYPTO_THREADID_cpy(&ret->tid, &tid); | 1026 | CRYPTO_THREADID_cpy(&ret->tid, &tid); |
| 999 | ret->top=0; | 1027 | ret->top = 0; |
| 1000 | ret->bottom=0; | 1028 | ret->bottom = 0; |
| 1001 | for (i=0; i<ERR_NUM_ERRORS; i++) | 1029 | for (i = 0; i < ERR_NUM_ERRORS; i++) { |
| 1002 | { | 1030 | ret->err_data[i] = NULL; |
| 1003 | ret->err_data[i]=NULL; | 1031 | ret->err_data_flags[i] = 0; |
| 1004 | ret->err_data_flags[i]=0; | 1032 | } |
| 1005 | } | ||
| 1006 | tmpp = ERRFN(thread_set_item)(ret); | 1033 | tmpp = ERRFN(thread_set_item)(ret); |
| 1007 | /* To check if insertion failed, do a get. */ | 1034 | /* To check if insertion failed, do a get. */ |
| 1008 | if (ERRFN(thread_get_item)(ret) != ret) | 1035 | if (ERRFN(thread_get_item)(ret) != ret) { |
| 1009 | { | ||
| 1010 | ERR_STATE_free(ret); /* could not insert it */ | 1036 | ERR_STATE_free(ret); /* could not insert it */ |
| 1011 | return(&fallback); | 1037 | return (&fallback); |
| 1012 | } | 1038 | } |
| 1013 | /* If a race occured in this function and we came second, tmpp | 1039 | /* If a race occured in this function and we came second, tmpp |
| 1014 | * is the first one that we just replaced. */ | 1040 | * is the first one that we just replaced. */ |
| 1015 | if (tmpp) | 1041 | if (tmpp) |
| 1016 | ERR_STATE_free(tmpp); | 1042 | ERR_STATE_free(tmpp); |
| 1017 | } | ||
| 1018 | return ret; | ||
| 1019 | } | 1043 | } |
| 1044 | return ret; | ||
| 1045 | } | ||
| 1020 | 1046 | ||
| 1021 | int ERR_get_next_error_library(void) | 1047 | int |
| 1022 | { | 1048 | ERR_get_next_error_library(void) |
| 1049 | { | ||
| 1023 | err_fns_check(); | 1050 | err_fns_check(); |
| 1024 | return ERRFN(get_next_lib)(); | 1051 | return ERRFN(get_next_lib)(); |
| 1025 | } | 1052 | } |
| 1026 | 1053 | ||
| 1027 | void ERR_set_error_data(char *data, int flags) | 1054 | void |
| 1028 | { | 1055 | ERR_set_error_data(char *data, int flags) |
| 1056 | { | ||
| 1029 | ERR_STATE *es; | 1057 | ERR_STATE *es; |
| 1030 | int i; | 1058 | int i; |
| 1031 | 1059 | ||
| 1032 | es=ERR_get_state(); | 1060 | es = ERR_get_state(); |
| 1033 | 1061 | ||
| 1034 | i=es->top; | 1062 | i = es->top; |
| 1035 | if (i == 0) | 1063 | if (i == 0) |
| 1036 | i=ERR_NUM_ERRORS-1; | 1064 | i = ERR_NUM_ERRORS - 1; |
| 1037 | 1065 | ||
| 1038 | err_clear_data(es,i); | 1066 | err_clear_data(es, i); |
| 1039 | es->err_data[i]=data; | 1067 | es->err_data[i] = data; |
| 1040 | es->err_data_flags[i]=flags; | 1068 | es->err_data_flags[i] = flags; |
| 1041 | } | 1069 | } |
| 1042 | 1070 | ||
| 1043 | void ERR_add_error_data(int num, ...) | 1071 | void |
| 1044 | { | 1072 | ERR_add_error_data(int num, ...) |
| 1073 | { | ||
| 1045 | va_list args; | 1074 | va_list args; |
| 1046 | va_start(args, num); | 1075 | va_start(args, num); |
| 1047 | ERR_add_error_vdata(num, args); | 1076 | ERR_add_error_vdata(num, args); |
| 1048 | va_end(args); | 1077 | va_end(args); |
| 1049 | } | 1078 | } |
| 1050 | 1079 | ||
| 1051 | void ERR_add_error_vdata(int num, va_list args) | 1080 | void |
| 1052 | { | 1081 | ERR_add_error_vdata(int num, va_list args) |
| 1053 | int i,n,s; | 1082 | { |
| 1054 | char *str,*p,*a; | 1083 | int i, n, s; |
| 1084 | char *str, *p, *a; | ||
| 1055 | 1085 | ||
| 1056 | s=80; | 1086 | s = 80; |
| 1057 | str=malloc(s+1); | 1087 | str = malloc(s + 1); |
| 1058 | if (str == NULL) return; | 1088 | if (str == NULL) |
| 1059 | str[0]='\0'; | 1089 | return; |
| 1090 | str[0] = '\0'; | ||
| 1060 | 1091 | ||
| 1061 | n=0; | 1092 | n = 0; |
| 1062 | for (i=0; i<num; i++) | 1093 | for (i = 0; i < num; i++) { |
| 1063 | { | 1094 | a = va_arg(args, char*); |
| 1064 | a=va_arg(args, char*); | ||
| 1065 | /* ignore NULLs, thanks to Bob Beck <beck@obtuse.com> */ | 1095 | /* ignore NULLs, thanks to Bob Beck <beck@obtuse.com> */ |
| 1066 | if (a != NULL) | 1096 | if (a != NULL) { |
| 1067 | { | 1097 | n += strlen(a); |
| 1068 | n+=strlen(a); | 1098 | if (n > s) { |
| 1069 | if (n > s) | 1099 | s = n + 20; |
| 1070 | { | 1100 | p = realloc(str, s + 1); |
| 1071 | s=n+20; | 1101 | if (p == NULL) { |
| 1072 | p=realloc(str,s+1); | ||
| 1073 | if (p == NULL) | ||
| 1074 | { | ||
| 1075 | free(str); | 1102 | free(str); |
| 1076 | return; | 1103 | return; |
| 1077 | } | 1104 | } else |
| 1078 | else | 1105 | str = p; |
| 1079 | str=p; | ||
| 1080 | } | ||
| 1081 | strlcat(str,a,(size_t)s+1); | ||
| 1082 | } | 1106 | } |
| 1107 | strlcat(str, a, (size_t)s + 1); | ||
| 1083 | } | 1108 | } |
| 1084 | ERR_set_error_data(str,ERR_TXT_MALLOCED|ERR_TXT_STRING); | ||
| 1085 | } | 1109 | } |
| 1110 | ERR_set_error_data(str, ERR_TXT_MALLOCED|ERR_TXT_STRING); | ||
| 1111 | } | ||
| 1086 | 1112 | ||
| 1087 | int ERR_set_mark(void) | 1113 | int |
| 1088 | { | 1114 | ERR_set_mark(void) |
| 1115 | { | ||
| 1089 | ERR_STATE *es; | 1116 | ERR_STATE *es; |
| 1090 | 1117 | ||
| 1091 | es=ERR_get_state(); | 1118 | es = ERR_get_state(); |
| 1092 | 1119 | ||
| 1093 | if (es->bottom == es->top) return 0; | 1120 | if (es->bottom == es->top) |
| 1094 | es->err_flags[es->top]|=ERR_FLAG_MARK; | 1121 | return 0; |
| 1122 | es->err_flags[es->top] |= ERR_FLAG_MARK; | ||
| 1095 | return 1; | 1123 | return 1; |
| 1096 | } | 1124 | } |
| 1097 | 1125 | ||
| 1098 | int ERR_pop_to_mark(void) | 1126 | int |
| 1099 | { | 1127 | ERR_pop_to_mark(void) |
| 1128 | { | ||
| 1100 | ERR_STATE *es; | 1129 | ERR_STATE *es; |
| 1101 | 1130 | ||
| 1102 | es=ERR_get_state(); | 1131 | es = ERR_get_state(); |
| 1103 | 1132 | ||
| 1104 | while(es->bottom != es->top | 1133 | while (es->bottom != es->top && |
| 1105 | && (es->err_flags[es->top] & ERR_FLAG_MARK) == 0) | 1134 | (es->err_flags[es->top] & ERR_FLAG_MARK) == 0) { |
| 1106 | { | 1135 | err_clear(es, es->top); |
| 1107 | err_clear(es,es->top); | 1136 | es->top -= 1; |
| 1108 | es->top-=1; | 1137 | if (es->top == -1) |
| 1109 | if (es->top == -1) es->top=ERR_NUM_ERRORS-1; | 1138 | es->top = ERR_NUM_ERRORS - 1; |
| 1110 | } | 1139 | } |
| 1111 | 1140 | ||
| 1112 | if (es->bottom == es->top) return 0; | 1141 | if (es->bottom == es->top) |
| 1142 | return 0; | ||
| 1113 | es->err_flags[es->top]&=~ERR_FLAG_MARK; | 1143 | es->err_flags[es->top]&=~ERR_FLAG_MARK; |
| 1114 | return 1; | 1144 | return 1; |
| 1115 | } | 1145 | } |
diff --git a/src/lib/libcrypto/err/err.h b/src/lib/libcrypto/err/err.h index 974cc9cc6f..87dfef2456 100644 --- a/src/lib/libcrypto/err/err.h +++ b/src/lib/libcrypto/err/err.h | |||
| @@ -5,21 +5,21 @@ | |||
| 5 | * This package is an SSL implementation written | 5 | * This package is an SSL implementation written |
| 6 | * by Eric Young (eay@cryptsoft.com). | 6 | * by Eric Young (eay@cryptsoft.com). |
| 7 | * The implementation was written so as to conform with Netscapes SSL. | 7 | * The implementation was written so as to conform with Netscapes SSL. |
| 8 | * | 8 | * |
| 9 | * This library is free for commercial and non-commercial use as long as | 9 | * This library is free for commercial and non-commercial use as long as |
| 10 | * the following conditions are aheared to. The following conditions | 10 | * the following conditions are aheared to. The following conditions |
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | 11 | * apply to all code found in this distribution, be it the RC4, RSA, |
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation |
| 13 | * included with this distribution is covered by the same copyright terms | 13 | * included with this distribution is covered by the same copyright terms |
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
| 15 | * | 15 | * |
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | 16 | * Copyright remains Eric Young's, and as such any Copyright notices in |
| 17 | * the code are not to be removed. | 17 | * the code are not to be removed. |
| 18 | * If this package is used in a product, Eric Young should be given attribution | 18 | * If this package is used in a product, Eric Young should be given attribution |
| 19 | * as the author of the parts of the library used. | 19 | * as the author of the parts of the library used. |
| 20 | * This can be in the form of a textual message at program startup or | 20 | * This can be in the form of a textual message at program startup or |
| 21 | * in documentation (online or textual) provided with the package. | 21 | * in documentation (online or textual) provided with the package. |
| 22 | * | 22 | * |
| 23 | * Redistribution and use in source and binary forms, with or without | 23 | * Redistribution and use in source and binary forms, with or without |
| 24 | * modification, are permitted provided that the following conditions | 24 | * modification, are permitted provided that the following conditions |
| 25 | * are met: | 25 | * are met: |
| @@ -34,10 +34,10 @@ | |||
| 34 | * Eric Young (eay@cryptsoft.com)" | 34 | * Eric Young (eay@cryptsoft.com)" |
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | 35 | * The word 'cryptographic' can be left out if the rouines from the library |
| 36 | * being used are not cryptographic related :-). | 36 | * being used are not cryptographic related :-). |
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | 37 | * 4. If you include any Windows specific code (or a derivative thereof) from |
| 38 | * the apps directory (application code) you must include an acknowledgement: | 38 | * the apps directory (application code) you must include an acknowledgement: |
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
| 40 | * | 40 | * |
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| @@ -49,7 +49,7 @@ | |||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. |
| 52 | * | 52 | * |
| 53 | * The licence and distribution terms for any publically available version or | 53 | * The licence and distribution terms for any publically available version or |
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
| 55 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
| @@ -63,7 +63,7 @@ | |||
| 63 | * are met: | 63 | * are met: |
| 64 | * | 64 | * |
| 65 | * 1. Redistributions of source code must retain the above copyright | 65 | * 1. Redistributions of source code must retain the above copyright |
| 66 | * notice, this list of conditions and the following disclaimer. | 66 | * notice, this list of conditions and the following disclaimer. |
| 67 | * | 67 | * |
| 68 | * 2. Redistributions in binary form must reproduce the above copyright | 68 | * 2. Redistributions in binary form must reproduce the above copyright |
| 69 | * notice, this list of conditions and the following disclaimer in | 69 | * notice, this list of conditions and the following disclaimer in |
| @@ -145,8 +145,7 @@ extern "C" { | |||
| 145 | #define ERR_FLAG_MARK 0x01 | 145 | #define ERR_FLAG_MARK 0x01 |
| 146 | 146 | ||
| 147 | #define ERR_NUM_ERRORS 16 | 147 | #define ERR_NUM_ERRORS 16 |
| 148 | typedef struct err_state_st | 148 | typedef struct err_state_st { |
| 149 | { | ||
| 150 | CRYPTO_THREADID tid; | 149 | CRYPTO_THREADID tid; |
| 151 | int err_flags[ERR_NUM_ERRORS]; | 150 | int err_flags[ERR_NUM_ERRORS]; |
| 152 | unsigned long err_buffer[ERR_NUM_ERRORS]; | 151 | unsigned long err_buffer[ERR_NUM_ERRORS]; |
| @@ -154,8 +153,8 @@ typedef struct err_state_st | |||
| 154 | int err_data_flags[ERR_NUM_ERRORS]; | 153 | int err_data_flags[ERR_NUM_ERRORS]; |
| 155 | const char *err_file[ERR_NUM_ERRORS]; | 154 | const char *err_file[ERR_NUM_ERRORS]; |
| 156 | int err_line[ERR_NUM_ERRORS]; | 155 | int err_line[ERR_NUM_ERRORS]; |
| 157 | int top,bottom; | 156 | int top, bottom; |
| 158 | } ERR_STATE; | 157 | } ERR_STATE; |
| 159 | 158 | ||
| 160 | /* library */ | 159 | /* library */ |
| 161 | #define ERR_LIB_NONE 1 | 160 | #define ERR_LIB_NONE 1 |
| @@ -310,35 +309,34 @@ typedef struct err_state_st | |||
| 310 | * are reserved for the individual libraries */ | 309 | * are reserved for the individual libraries */ |
| 311 | 310 | ||
| 312 | 311 | ||
| 313 | typedef struct ERR_string_data_st | 312 | typedef struct ERR_string_data_st { |
| 314 | { | ||
| 315 | unsigned long error; | 313 | unsigned long error; |
| 316 | const char *string; | 314 | const char *string; |
| 317 | } ERR_STRING_DATA; | 315 | } ERR_STRING_DATA; |
| 318 | 316 | ||
| 319 | void ERR_put_error(int lib, int func,int reason,const char *file,int line); | 317 | void ERR_put_error(int lib, int func, int reason, const char *file, int line); |
| 320 | void ERR_set_error_data(char *data,int flags); | 318 | void ERR_set_error_data(char *data, int flags); |
| 321 | 319 | ||
| 322 | unsigned long ERR_get_error(void); | 320 | unsigned long ERR_get_error(void); |
| 323 | unsigned long ERR_get_error_line(const char **file,int *line); | 321 | unsigned long ERR_get_error_line(const char **file, int *line); |
| 324 | unsigned long ERR_get_error_line_data(const char **file,int *line, | 322 | unsigned long ERR_get_error_line_data(const char **file, int *line, |
| 325 | const char **data, int *flags); | 323 | const char **data, int *flags); |
| 326 | unsigned long ERR_peek_error(void); | 324 | unsigned long ERR_peek_error(void); |
| 327 | unsigned long ERR_peek_error_line(const char **file,int *line); | 325 | unsigned long ERR_peek_error_line(const char **file, int *line); |
| 328 | unsigned long ERR_peek_error_line_data(const char **file,int *line, | 326 | unsigned long ERR_peek_error_line_data(const char **file, int *line, |
| 329 | const char **data,int *flags); | 327 | const char **data, int *flags); |
| 330 | unsigned long ERR_peek_last_error(void); | 328 | unsigned long ERR_peek_last_error(void); |
| 331 | unsigned long ERR_peek_last_error_line(const char **file,int *line); | 329 | unsigned long ERR_peek_last_error_line(const char **file, int *line); |
| 332 | unsigned long ERR_peek_last_error_line_data(const char **file,int *line, | 330 | unsigned long ERR_peek_last_error_line_data(const char **file, int *line, |
| 333 | const char **data,int *flags); | 331 | const char **data, int *flags); |
| 334 | void ERR_clear_error(void ); | 332 | void ERR_clear_error(void ); |
| 335 | char *ERR_error_string(unsigned long e,char *buf); | 333 | char *ERR_error_string(unsigned long e, char *buf); |
| 336 | void ERR_error_string_n(unsigned long e, char *buf, size_t len); | 334 | void ERR_error_string_n(unsigned long e, char *buf, size_t len); |
| 337 | const char *ERR_lib_error_string(unsigned long e); | 335 | const char *ERR_lib_error_string(unsigned long e); |
| 338 | const char *ERR_func_error_string(unsigned long e); | 336 | const char *ERR_func_error_string(unsigned long e); |
| 339 | const char *ERR_reason_error_string(unsigned long e); | 337 | const char *ERR_reason_error_string(unsigned long e); |
| 340 | void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u), | 338 | void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u), |
| 341 | void *u); | 339 | void *u); |
| 342 | #ifndef OPENSSL_NO_FP_API | 340 | #ifndef OPENSSL_NO_FP_API |
| 343 | void ERR_print_errors_fp(FILE *fp); | 341 | void ERR_print_errors_fp(FILE *fp); |
| 344 | #endif | 342 | #endif |
| @@ -347,8 +345,8 @@ void ERR_print_errors(BIO *bp); | |||
| 347 | #endif | 345 | #endif |
| 348 | void ERR_add_error_data(int num, ...); | 346 | void ERR_add_error_data(int num, ...); |
| 349 | void ERR_add_error_vdata(int num, va_list args); | 347 | void ERR_add_error_vdata(int num, va_list args); |
| 350 | void ERR_load_strings(int lib,ERR_STRING_DATA str[]); | 348 | void ERR_load_strings(int lib, ERR_STRING_DATA str[]); |
| 351 | void ERR_unload_strings(int lib,ERR_STRING_DATA str[]); | 349 | void ERR_unload_strings(int lib, ERR_STRING_DATA str[]); |
| 352 | void ERR_load_ERR_strings(void); | 350 | void ERR_load_ERR_strings(void); |
| 353 | void ERR_load_crypto_strings(void); | 351 | void ERR_load_crypto_strings(void); |
| 354 | void ERR_free_strings(void); | 352 | void ERR_free_strings(void); |
diff --git a/src/lib/libcrypto/err/err_all.c b/src/lib/libcrypto/err/err_all.c index 1c4eccd251..1350c61296 100644 --- a/src/lib/libcrypto/err/err_all.c +++ b/src/lib/libcrypto/err/err_all.c | |||
| @@ -5,21 +5,21 @@ | |||
| 5 | * This package is an SSL implementation written | 5 | * This package is an SSL implementation written |
| 6 | * by Eric Young (eay@cryptsoft.com). | 6 | * by Eric Young (eay@cryptsoft.com). |
| 7 | * The implementation was written so as to conform with Netscapes SSL. | 7 | * The implementation was written so as to conform with Netscapes SSL. |
| 8 | * | 8 | * |
| 9 | * This library is free for commercial and non-commercial use as long as | 9 | * This library is free for commercial and non-commercial use as long as |
| 10 | * the following conditions are aheared to. The following conditions | 10 | * the following conditions are aheared to. The following conditions |
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | 11 | * apply to all code found in this distribution, be it the RC4, RSA, |
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation |
| 13 | * included with this distribution is covered by the same copyright terms | 13 | * included with this distribution is covered by the same copyright terms |
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
| 15 | * | 15 | * |
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | 16 | * Copyright remains Eric Young's, and as such any Copyright notices in |
| 17 | * the code are not to be removed. | 17 | * the code are not to be removed. |
| 18 | * If this package is used in a product, Eric Young should be given attribution | 18 | * If this package is used in a product, Eric Young should be given attribution |
| 19 | * as the author of the parts of the library used. | 19 | * as the author of the parts of the library used. |
| 20 | * This can be in the form of a textual message at program startup or | 20 | * This can be in the form of a textual message at program startup or |
| 21 | * in documentation (online or textual) provided with the package. | 21 | * in documentation (online or textual) provided with the package. |
| 22 | * | 22 | * |
| 23 | * Redistribution and use in source and binary forms, with or without | 23 | * Redistribution and use in source and binary forms, with or without |
| 24 | * modification, are permitted provided that the following conditions | 24 | * modification, are permitted provided that the following conditions |
| 25 | * are met: | 25 | * are met: |
| @@ -34,10 +34,10 @@ | |||
| 34 | * Eric Young (eay@cryptsoft.com)" | 34 | * Eric Young (eay@cryptsoft.com)" |
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | 35 | * The word 'cryptographic' can be left out if the rouines from the library |
| 36 | * being used are not cryptographic related :-). | 36 | * being used are not cryptographic related :-). |
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | 37 | * 4. If you include any Windows specific code (or a derivative thereof) from |
| 38 | * the apps directory (application code) you must include an acknowledgement: | 38 | * the apps directory (application code) you must include an acknowledgement: |
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
| 40 | * | 40 | * |
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| @@ -49,7 +49,7 @@ | |||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. |
| 52 | * | 52 | * |
| 53 | * The licence and distribution terms for any publically available version or | 53 | * The licence and distribution terms for any publically available version or |
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
| 55 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
| @@ -105,8 +105,9 @@ | |||
| 105 | #include <openssl/jpake.h> | 105 | #include <openssl/jpake.h> |
| 106 | #endif | 106 | #endif |
| 107 | 107 | ||
| 108 | void ERR_load_crypto_strings(void) | 108 | void |
| 109 | { | 109 | ERR_load_crypto_strings(void) |
| 110 | { | ||
| 110 | #ifndef OPENSSL_NO_ERR | 111 | #ifndef OPENSSL_NO_ERR |
| 111 | ERR_load_ERR_strings(); /* include error strings for SYSerr */ | 112 | ERR_load_ERR_strings(); /* include error strings for SYSerr */ |
| 112 | ERR_load_BN_strings(); | 113 | ERR_load_BN_strings(); |
| @@ -141,7 +142,7 @@ void ERR_load_crypto_strings(void) | |||
| 141 | #endif | 142 | #endif |
| 142 | /* skip ERR_load_SSL_strings() because it is not in this library */ | 143 | /* skip ERR_load_SSL_strings() because it is not in this library */ |
| 143 | ERR_load_BIO_strings(); | 144 | ERR_load_BIO_strings(); |
| 144 | ERR_load_PKCS7_strings(); | 145 | ERR_load_PKCS7_strings(); |
| 145 | ERR_load_X509V3_strings(); | 146 | ERR_load_X509V3_strings(); |
| 146 | ERR_load_PKCS12_strings(); | 147 | ERR_load_PKCS12_strings(); |
| 147 | ERR_load_RAND_strings(); | 148 | ERR_load_RAND_strings(); |
| @@ -159,4 +160,4 @@ void ERR_load_crypto_strings(void) | |||
| 159 | ERR_load_JPAKE_strings(); | 160 | ERR_load_JPAKE_strings(); |
| 160 | #endif | 161 | #endif |
| 161 | #endif | 162 | #endif |
| 162 | } | 163 | } |
diff --git a/src/lib/libcrypto/err/err_prn.c b/src/lib/libcrypto/err/err_prn.c index 7374c0abe7..d6b488fee9 100644 --- a/src/lib/libcrypto/err/err_prn.c +++ b/src/lib/libcrypto/err/err_prn.c | |||
| @@ -5,21 +5,21 @@ | |||
| 5 | * This package is an SSL implementation written | 5 | * This package is an SSL implementation written |
| 6 | * by Eric Young (eay@cryptsoft.com). | 6 | * by Eric Young (eay@cryptsoft.com). |
| 7 | * The implementation was written so as to conform with Netscapes SSL. | 7 | * The implementation was written so as to conform with Netscapes SSL. |
| 8 | * | 8 | * |
| 9 | * This library is free for commercial and non-commercial use as long as | 9 | * This library is free for commercial and non-commercial use as long as |
| 10 | * the following conditions are aheared to. The following conditions | 10 | * the following conditions are aheared to. The following conditions |
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | 11 | * apply to all code found in this distribution, be it the RC4, RSA, |
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation |
| 13 | * included with this distribution is covered by the same copyright terms | 13 | * included with this distribution is covered by the same copyright terms |
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
| 15 | * | 15 | * |
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | 16 | * Copyright remains Eric Young's, and as such any Copyright notices in |
| 17 | * the code are not to be removed. | 17 | * the code are not to be removed. |
| 18 | * If this package is used in a product, Eric Young should be given attribution | 18 | * If this package is used in a product, Eric Young should be given attribution |
| 19 | * as the author of the parts of the library used. | 19 | * as the author of the parts of the library used. |
| 20 | * This can be in the form of a textual message at program startup or | 20 | * This can be in the form of a textual message at program startup or |
| 21 | * in documentation (online or textual) provided with the package. | 21 | * in documentation (online or textual) provided with the package. |
| 22 | * | 22 | * |
| 23 | * Redistribution and use in source and binary forms, with or without | 23 | * Redistribution and use in source and binary forms, with or without |
| 24 | * modification, are permitted provided that the following conditions | 24 | * modification, are permitted provided that the following conditions |
| 25 | * are met: | 25 | * are met: |
| @@ -34,10 +34,10 @@ | |||
| 34 | * Eric Young (eay@cryptsoft.com)" | 34 | * Eric Young (eay@cryptsoft.com)" |
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | 35 | * The word 'cryptographic' can be left out if the rouines from the library |
| 36 | * being used are not cryptographic related :-). | 36 | * being used are not cryptographic related :-). |
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | 37 | * 4. If you include any Windows specific code (or a derivative thereof) from |
| 38 | * the apps directory (application code) you must include an acknowledgement: | 38 | * the apps directory (application code) you must include an acknowledgement: |
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
| 40 | * | 40 | * |
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| @@ -49,7 +49,7 @@ | |||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. |
| 52 | * | 52 | * |
| 53 | * The licence and distribution terms for any publically available version or | 53 | * The licence and distribution terms for any publically available version or |
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
| 55 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
| @@ -63,52 +63,56 @@ | |||
| 63 | #include <openssl/buffer.h> | 63 | #include <openssl/buffer.h> |
| 64 | #include <openssl/err.h> | 64 | #include <openssl/err.h> |
| 65 | 65 | ||
| 66 | void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u), | 66 | void |
| 67 | void *u) | 67 | ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u), void *u) |
| 68 | { | 68 | { |
| 69 | unsigned long l; | 69 | unsigned long l; |
| 70 | char buf[256]; | 70 | char buf[256]; |
| 71 | char buf2[4096]; | 71 | char buf2[4096]; |
| 72 | const char *file,*data; | 72 | const char *file, *data; |
| 73 | int line,flags; | 73 | int line, flags; |
| 74 | unsigned long es; | 74 | unsigned long es; |
| 75 | CRYPTO_THREADID cur; | 75 | CRYPTO_THREADID cur; |
| 76 | 76 | ||
| 77 | CRYPTO_THREADID_current(&cur); | 77 | CRYPTO_THREADID_current(&cur); |
| 78 | es=CRYPTO_THREADID_hash(&cur); | 78 | es = CRYPTO_THREADID_hash(&cur); |
| 79 | while ((l=ERR_get_error_line_data(&file,&line,&data,&flags)) != 0) | 79 | while ((l = ERR_get_error_line_data(&file, &line, &data, |
| 80 | { | 80 | &flags)) != 0) { |
| 81 | ERR_error_string_n(l, buf, sizeof buf); | 81 | ERR_error_string_n(l, buf, sizeof buf); |
| 82 | (void) snprintf(buf2, sizeof(buf2), "%lu:%s:%s:%d:%s\n", es, buf, | 82 | (void) snprintf(buf2, sizeof(buf2), "%lu:%s:%s:%d:%s\n", es, |
| 83 | file, line, (flags & ERR_TXT_STRING) ? data : ""); | 83 | buf, file, line, (flags & ERR_TXT_STRING) ? data : ""); |
| 84 | if (cb(buf2, strlen(buf2), u) <= 0) | 84 | if (cb(buf2, strlen(buf2), u) <= 0) |
| 85 | break; /* abort outputting the error report */ | 85 | break; /* abort outputting the error report */ |
| 86 | } | ||
| 87 | } | 86 | } |
| 87 | } | ||
| 88 | 88 | ||
| 89 | #ifndef OPENSSL_NO_FP_API | 89 | #ifndef OPENSSL_NO_FP_API |
| 90 | static int print_fp(const char *str, size_t len, void *fp) | 90 | static int |
| 91 | { | 91 | print_fp(const char *str, size_t len, void *fp) |
| 92 | { | ||
| 92 | BIO bio; | 93 | BIO bio; |
| 93 | 94 | ||
| 94 | BIO_set(&bio,BIO_s_file()); | 95 | BIO_set(&bio, BIO_s_file()); |
| 95 | BIO_set_fp(&bio,fp,BIO_NOCLOSE); | 96 | BIO_set_fp(&bio, fp, BIO_NOCLOSE); |
| 96 | 97 | ||
| 97 | return BIO_printf(&bio, "%s", str); | 98 | return BIO_printf(&bio, "%s", str); |
| 98 | } | 99 | } |
| 99 | void ERR_print_errors_fp(FILE *fp) | 100 | |
| 100 | { | 101 | void |
| 102 | ERR_print_errors_fp(FILE *fp) | ||
| 103 | { | ||
| 101 | ERR_print_errors_cb(print_fp, fp); | 104 | ERR_print_errors_cb(print_fp, fp); |
| 102 | } | 105 | } |
| 103 | #endif | 106 | #endif |
| 104 | 107 | ||
| 105 | static int print_bio(const char *str, size_t len, void *bp) | 108 | static int |
| 106 | { | 109 | print_bio(const char *str, size_t len, void *bp) |
| 110 | { | ||
| 107 | return BIO_write((BIO *)bp, str, len); | 111 | return BIO_write((BIO *)bp, str, len); |
| 108 | } | 112 | } |
| 109 | void ERR_print_errors(BIO *bp) | ||
| 110 | { | ||
| 111 | ERR_print_errors_cb(print_bio, bp); | ||
| 112 | } | ||
| 113 | 113 | ||
| 114 | 114 | void | |
| 115 | ERR_print_errors(BIO *bp) | ||
| 116 | { | ||
| 117 | ERR_print_errors_cb(print_bio, bp); | ||
| 118 | } | ||
diff --git a/src/lib/libssl/src/crypto/err/err.c b/src/lib/libssl/src/crypto/err/err.c index c44a065486..eaafb29101 100644 --- a/src/lib/libssl/src/crypto/err/err.c +++ b/src/lib/libssl/src/crypto/err/err.c | |||
| @@ -5,21 +5,21 @@ | |||
| 5 | * This package is an SSL implementation written | 5 | * This package is an SSL implementation written |
| 6 | * by Eric Young (eay@cryptsoft.com). | 6 | * by Eric Young (eay@cryptsoft.com). |
| 7 | * The implementation was written so as to conform with Netscapes SSL. | 7 | * The implementation was written so as to conform with Netscapes SSL. |
| 8 | * | 8 | * |
| 9 | * This library is free for commercial and non-commercial use as long as | 9 | * This library is free for commercial and non-commercial use as long as |
| 10 | * the following conditions are aheared to. The following conditions | 10 | * the following conditions are aheared to. The following conditions |
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | 11 | * apply to all code found in this distribution, be it the RC4, RSA, |
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation |
| 13 | * included with this distribution is covered by the same copyright terms | 13 | * included with this distribution is covered by the same copyright terms |
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
| 15 | * | 15 | * |
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | 16 | * Copyright remains Eric Young's, and as such any Copyright notices in |
| 17 | * the code are not to be removed. | 17 | * the code are not to be removed. |
| 18 | * If this package is used in a product, Eric Young should be given attribution | 18 | * If this package is used in a product, Eric Young should be given attribution |
| 19 | * as the author of the parts of the library used. | 19 | * as the author of the parts of the library used. |
| 20 | * This can be in the form of a textual message at program startup or | 20 | * This can be in the form of a textual message at program startup or |
| 21 | * in documentation (online or textual) provided with the package. | 21 | * in documentation (online or textual) provided with the package. |
| 22 | * | 22 | * |
| 23 | * Redistribution and use in source and binary forms, with or without | 23 | * Redistribution and use in source and binary forms, with or without |
| 24 | * modification, are permitted provided that the following conditions | 24 | * modification, are permitted provided that the following conditions |
| 25 | * are met: | 25 | * are met: |
| @@ -34,10 +34,10 @@ | |||
| 34 | * Eric Young (eay@cryptsoft.com)" | 34 | * Eric Young (eay@cryptsoft.com)" |
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | 35 | * The word 'cryptographic' can be left out if the rouines from the library |
| 36 | * being used are not cryptographic related :-). | 36 | * being used are not cryptographic related :-). |
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | 37 | * 4. If you include any Windows specific code (or a derivative thereof) from |
| 38 | * the apps directory (application code) you must include an acknowledgement: | 38 | * the apps directory (application code) you must include an acknowledgement: |
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
| 40 | * | 40 | * |
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| @@ -49,7 +49,7 @@ | |||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. |
| 52 | * | 52 | * |
| 53 | * The licence and distribution terms for any publically available version or | 53 | * The licence and distribution terms for any publically available version or |
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
| 55 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
| @@ -63,7 +63,7 @@ | |||
| 63 | * are met: | 63 | * are met: |
| 64 | * | 64 | * |
| 65 | * 1. Redistributions of source code must retain the above copyright | 65 | * 1. Redistributions of source code must retain the above copyright |
| 66 | * notice, this list of conditions and the following disclaimer. | 66 | * notice, this list of conditions and the following disclaimer. |
| 67 | * | 67 | * |
| 68 | * 2. Redistributions in binary form must reproduce the above copyright | 68 | * 2. Redistributions in binary form must reproduce the above copyright |
| 69 | * notice, this list of conditions and the following disclaimer in | 69 | * notice, this list of conditions and the following disclaimer in |
| @@ -126,106 +126,102 @@ static void err_load_strings(int lib, ERR_STRING_DATA *str); | |||
| 126 | 126 | ||
| 127 | static void ERR_STATE_free(ERR_STATE *s); | 127 | static void ERR_STATE_free(ERR_STATE *s); |
| 128 | #ifndef OPENSSL_NO_ERR | 128 | #ifndef OPENSSL_NO_ERR |
| 129 | static ERR_STRING_DATA ERR_str_libraries[]= | 129 | static ERR_STRING_DATA ERR_str_libraries[] = { |
| 130 | { | 130 | {ERR_PACK(ERR_LIB_NONE,0,0) , "unknown library"}, |
| 131 | {ERR_PACK(ERR_LIB_NONE,0,0) ,"unknown library"}, | 131 | {ERR_PACK(ERR_LIB_SYS,0,0) , "system library"}, |
| 132 | {ERR_PACK(ERR_LIB_SYS,0,0) ,"system library"}, | 132 | {ERR_PACK(ERR_LIB_BN,0,0) , "bignum routines"}, |
| 133 | {ERR_PACK(ERR_LIB_BN,0,0) ,"bignum routines"}, | 133 | {ERR_PACK(ERR_LIB_RSA,0,0) , "rsa routines"}, |
| 134 | {ERR_PACK(ERR_LIB_RSA,0,0) ,"rsa routines"}, | 134 | {ERR_PACK(ERR_LIB_DH,0,0) , "Diffie-Hellman routines"}, |
| 135 | {ERR_PACK(ERR_LIB_DH,0,0) ,"Diffie-Hellman routines"}, | 135 | {ERR_PACK(ERR_LIB_EVP,0,0) , "digital envelope routines"}, |
| 136 | {ERR_PACK(ERR_LIB_EVP,0,0) ,"digital envelope routines"}, | 136 | {ERR_PACK(ERR_LIB_BUF,0,0) , "memory buffer routines"}, |
| 137 | {ERR_PACK(ERR_LIB_BUF,0,0) ,"memory buffer routines"}, | 137 | {ERR_PACK(ERR_LIB_OBJ,0,0) , "object identifier routines"}, |
| 138 | {ERR_PACK(ERR_LIB_OBJ,0,0) ,"object identifier routines"}, | 138 | {ERR_PACK(ERR_LIB_PEM,0,0) , "PEM routines"}, |
| 139 | {ERR_PACK(ERR_LIB_PEM,0,0) ,"PEM routines"}, | 139 | {ERR_PACK(ERR_LIB_DSA,0,0) , "dsa routines"}, |
| 140 | {ERR_PACK(ERR_LIB_DSA,0,0) ,"dsa routines"}, | 140 | {ERR_PACK(ERR_LIB_X509,0,0) , "x509 certificate routines"}, |
| 141 | {ERR_PACK(ERR_LIB_X509,0,0) ,"x509 certificate routines"}, | 141 | {ERR_PACK(ERR_LIB_ASN1,0,0) , "asn1 encoding routines"}, |
| 142 | {ERR_PACK(ERR_LIB_ASN1,0,0) ,"asn1 encoding routines"}, | 142 | {ERR_PACK(ERR_LIB_CONF,0,0) , "configuration file routines"}, |
| 143 | {ERR_PACK(ERR_LIB_CONF,0,0) ,"configuration file routines"}, | 143 | {ERR_PACK(ERR_LIB_CRYPTO,0,0) , "common libcrypto routines"}, |
| 144 | {ERR_PACK(ERR_LIB_CRYPTO,0,0) ,"common libcrypto routines"}, | 144 | {ERR_PACK(ERR_LIB_EC,0,0) , "elliptic curve routines"}, |
| 145 | {ERR_PACK(ERR_LIB_EC,0,0) ,"elliptic curve routines"}, | 145 | {ERR_PACK(ERR_LIB_SSL,0,0) , "SSL routines"}, |
| 146 | {ERR_PACK(ERR_LIB_SSL,0,0) ,"SSL routines"}, | 146 | {ERR_PACK(ERR_LIB_BIO,0,0) , "BIO routines"}, |
| 147 | {ERR_PACK(ERR_LIB_BIO,0,0) ,"BIO routines"}, | 147 | {ERR_PACK(ERR_LIB_PKCS7,0,0) , "PKCS7 routines"}, |
| 148 | {ERR_PACK(ERR_LIB_PKCS7,0,0) ,"PKCS7 routines"}, | 148 | {ERR_PACK(ERR_LIB_X509V3,0,0) , "X509 V3 routines"}, |
| 149 | {ERR_PACK(ERR_LIB_X509V3,0,0) ,"X509 V3 routines"}, | 149 | {ERR_PACK(ERR_LIB_PKCS12,0,0) , "PKCS12 routines"}, |
| 150 | {ERR_PACK(ERR_LIB_PKCS12,0,0) ,"PKCS12 routines"}, | 150 | {ERR_PACK(ERR_LIB_RAND,0,0) , "random number generator"}, |
| 151 | {ERR_PACK(ERR_LIB_RAND,0,0) ,"random number generator"}, | 151 | {ERR_PACK(ERR_LIB_DSO,0,0) , "DSO support routines"}, |
| 152 | {ERR_PACK(ERR_LIB_DSO,0,0) ,"DSO support routines"}, | 152 | {ERR_PACK(ERR_LIB_TS,0,0) , "time stamp routines"}, |
| 153 | {ERR_PACK(ERR_LIB_TS,0,0) ,"time stamp routines"}, | 153 | {ERR_PACK(ERR_LIB_ENGINE,0,0) , "engine routines"}, |
| 154 | {ERR_PACK(ERR_LIB_ENGINE,0,0) ,"engine routines"}, | 154 | {ERR_PACK(ERR_LIB_OCSP,0,0) , "OCSP routines"}, |
| 155 | {ERR_PACK(ERR_LIB_OCSP,0,0) ,"OCSP routines"}, | 155 | {ERR_PACK(ERR_LIB_FIPS,0,0) , "FIPS routines"}, |
| 156 | {ERR_PACK(ERR_LIB_FIPS,0,0) ,"FIPS routines"}, | 156 | {ERR_PACK(ERR_LIB_CMS,0,0) , "CMS routines"}, |
| 157 | {ERR_PACK(ERR_LIB_CMS,0,0) ,"CMS routines"}, | 157 | {ERR_PACK(ERR_LIB_HMAC,0,0) , "HMAC routines"}, |
| 158 | {ERR_PACK(ERR_LIB_HMAC,0,0) ,"HMAC routines"}, | 158 | {0, NULL}, |
| 159 | {0,NULL}, | 159 | }; |
| 160 | }; | 160 | |
| 161 | 161 | static ERR_STRING_DATA ERR_str_functs[] = { | |
| 162 | static ERR_STRING_DATA ERR_str_functs[]= | 162 | {ERR_PACK(0,SYS_F_FOPEN, 0), "fopen"}, |
| 163 | { | 163 | {ERR_PACK(0,SYS_F_CONNECT, 0), "connect"}, |
| 164 | {ERR_PACK(0,SYS_F_FOPEN,0), "fopen"}, | 164 | {ERR_PACK(0,SYS_F_GETSERVBYNAME, 0), "getservbyname"}, |
| 165 | {ERR_PACK(0,SYS_F_CONNECT,0), "connect"}, | 165 | {ERR_PACK(0,SYS_F_SOCKET, 0), "socket"}, |
| 166 | {ERR_PACK(0,SYS_F_GETSERVBYNAME,0), "getservbyname"}, | 166 | {ERR_PACK(0,SYS_F_IOCTLSOCKET, 0), "ioctl"}, |
| 167 | {ERR_PACK(0,SYS_F_SOCKET,0), "socket"}, | 167 | {ERR_PACK(0,SYS_F_BIND, 0), "bind"}, |
| 168 | {ERR_PACK(0,SYS_F_IOCTLSOCKET,0), "ioctl"}, | 168 | {ERR_PACK(0,SYS_F_LISTEN, 0), "listen"}, |
| 169 | {ERR_PACK(0,SYS_F_BIND,0), "bind"}, | 169 | {ERR_PACK(0,SYS_F_ACCEPT, 0), "accept"}, |
| 170 | {ERR_PACK(0,SYS_F_LISTEN,0), "listen"}, | ||
| 171 | {ERR_PACK(0,SYS_F_ACCEPT,0), "accept"}, | ||
| 172 | #ifdef OPENSSL_SYS_WINDOWS | 170 | #ifdef OPENSSL_SYS_WINDOWS |
| 173 | {ERR_PACK(0,SYS_F_WSASTARTUP,0), "WSAstartup"}, | 171 | {ERR_PACK(0,SYS_F_WSASTARTUP, 0), "WSAstartup"}, |
| 174 | #endif | 172 | #endif |
| 175 | {ERR_PACK(0,SYS_F_OPENDIR,0), "opendir"}, | 173 | {ERR_PACK(0,SYS_F_OPENDIR, 0), "opendir"}, |
| 176 | {ERR_PACK(0,SYS_F_FREAD,0), "fread"}, | 174 | {ERR_PACK(0,SYS_F_FREAD, 0), "fread"}, |
| 177 | {0,NULL}, | 175 | {0, NULL}, |
| 178 | }; | 176 | }; |
| 179 | 177 | ||
| 180 | static ERR_STRING_DATA ERR_str_reasons[]= | 178 | static ERR_STRING_DATA ERR_str_reasons[] = { |
| 181 | { | 179 | {ERR_R_SYS_LIB , "system lib"}, |
| 182 | {ERR_R_SYS_LIB ,"system lib"}, | 180 | {ERR_R_BN_LIB , "BN lib"}, |
| 183 | {ERR_R_BN_LIB ,"BN lib"}, | 181 | {ERR_R_RSA_LIB , "RSA lib"}, |
| 184 | {ERR_R_RSA_LIB ,"RSA lib"}, | 182 | {ERR_R_DH_LIB , "DH lib"}, |
| 185 | {ERR_R_DH_LIB ,"DH lib"}, | 183 | {ERR_R_EVP_LIB , "EVP lib"}, |
| 186 | {ERR_R_EVP_LIB ,"EVP lib"}, | 184 | {ERR_R_BUF_LIB , "BUF lib"}, |
| 187 | {ERR_R_BUF_LIB ,"BUF lib"}, | 185 | {ERR_R_OBJ_LIB , "OBJ lib"}, |
| 188 | {ERR_R_OBJ_LIB ,"OBJ lib"}, | 186 | {ERR_R_PEM_LIB , "PEM lib"}, |
| 189 | {ERR_R_PEM_LIB ,"PEM lib"}, | 187 | {ERR_R_DSA_LIB , "DSA lib"}, |
| 190 | {ERR_R_DSA_LIB ,"DSA lib"}, | 188 | {ERR_R_X509_LIB , "X509 lib"}, |
| 191 | {ERR_R_X509_LIB ,"X509 lib"}, | 189 | {ERR_R_ASN1_LIB , "ASN1 lib"}, |
| 192 | {ERR_R_ASN1_LIB ,"ASN1 lib"}, | 190 | {ERR_R_CONF_LIB , "CONF lib"}, |
| 193 | {ERR_R_CONF_LIB ,"CONF lib"}, | 191 | {ERR_R_CRYPTO_LIB , "CRYPTO lib"}, |
| 194 | {ERR_R_CRYPTO_LIB ,"CRYPTO lib"}, | 192 | {ERR_R_EC_LIB , "EC lib"}, |
| 195 | {ERR_R_EC_LIB ,"EC lib"}, | 193 | {ERR_R_SSL_LIB , "SSL lib"}, |
| 196 | {ERR_R_SSL_LIB ,"SSL lib"}, | 194 | {ERR_R_BIO_LIB , "BIO lib"}, |
| 197 | {ERR_R_BIO_LIB ,"BIO lib"}, | 195 | {ERR_R_PKCS7_LIB , "PKCS7 lib"}, |
| 198 | {ERR_R_PKCS7_LIB ,"PKCS7 lib"}, | 196 | {ERR_R_X509V3_LIB , "X509V3 lib"}, |
| 199 | {ERR_R_X509V3_LIB ,"X509V3 lib"}, | 197 | {ERR_R_PKCS12_LIB , "PKCS12 lib"}, |
| 200 | {ERR_R_PKCS12_LIB ,"PKCS12 lib"}, | 198 | {ERR_R_RAND_LIB , "RAND lib"}, |
| 201 | {ERR_R_RAND_LIB ,"RAND lib"}, | 199 | {ERR_R_DSO_LIB , "DSO lib"}, |
| 202 | {ERR_R_DSO_LIB ,"DSO lib"}, | 200 | {ERR_R_ENGINE_LIB , "ENGINE lib"}, |
| 203 | {ERR_R_ENGINE_LIB ,"ENGINE lib"}, | 201 | {ERR_R_OCSP_LIB , "OCSP lib"}, |
| 204 | {ERR_R_OCSP_LIB ,"OCSP lib"}, | 202 | {ERR_R_TS_LIB , "TS lib"}, |
| 205 | {ERR_R_TS_LIB ,"TS lib"}, | 203 | |
| 206 | 204 | {ERR_R_NESTED_ASN1_ERROR , "nested asn1 error"}, | |
| 207 | {ERR_R_NESTED_ASN1_ERROR ,"nested asn1 error"}, | 205 | {ERR_R_BAD_ASN1_OBJECT_HEADER , "bad asn1 object header"}, |
| 208 | {ERR_R_BAD_ASN1_OBJECT_HEADER ,"bad asn1 object header"}, | 206 | {ERR_R_BAD_GET_ASN1_OBJECT_CALL , "bad get asn1 object call"}, |
| 209 | {ERR_R_BAD_GET_ASN1_OBJECT_CALL ,"bad get asn1 object call"}, | 207 | {ERR_R_EXPECTING_AN_ASN1_SEQUENCE , "expecting an asn1 sequence"}, |
| 210 | {ERR_R_EXPECTING_AN_ASN1_SEQUENCE ,"expecting an asn1 sequence"}, | 208 | {ERR_R_ASN1_LENGTH_MISMATCH , "asn1 length mismatch"}, |
| 211 | {ERR_R_ASN1_LENGTH_MISMATCH ,"asn1 length mismatch"}, | 209 | {ERR_R_MISSING_ASN1_EOS , "missing asn1 eos"}, |
| 212 | {ERR_R_MISSING_ASN1_EOS ,"missing asn1 eos"}, | 210 | |
| 213 | 211 | {ERR_R_FATAL , "fatal"}, | |
| 214 | {ERR_R_FATAL ,"fatal"}, | 212 | {ERR_R_MALLOC_FAILURE , "malloc failure"}, |
| 215 | {ERR_R_MALLOC_FAILURE ,"malloc failure"}, | 213 | {ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED , "called a function you should not call"}, |
| 216 | {ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED ,"called a function you should not call"}, | 214 | {ERR_R_PASSED_NULL_PARAMETER , "passed a null parameter"}, |
| 217 | {ERR_R_PASSED_NULL_PARAMETER ,"passed a null parameter"}, | 215 | {ERR_R_INTERNAL_ERROR , "internal error"}, |
| 218 | {ERR_R_INTERNAL_ERROR ,"internal error"}, | 216 | {ERR_R_DISABLED , "called a function that was disabled at compile-time"}, |
| 219 | {ERR_R_DISABLED ,"called a function that was disabled at compile-time"}, | 217 | |
| 220 | 218 | {0, NULL}, | |
| 221 | {0,NULL}, | 219 | }; |
| 222 | }; | ||
| 223 | #endif | 220 | #endif |
| 224 | 221 | ||
| 225 | 222 | ||
| 226 | /* Define the predeclared (but externally opaque) "ERR_FNS" type */ | 223 | /* Define the predeclared (but externally opaque) "ERR_FNS" type */ |
| 227 | struct st_ERR_FNS | 224 | struct st_ERR_FNS { |
| 228 | { | ||
| 229 | /* Works on the "error_hash" string table */ | 225 | /* Works on the "error_hash" string table */ |
| 230 | LHASH_OF(ERR_STRING_DATA) *(*cb_err_get)(int create); | 226 | LHASH_OF(ERR_STRING_DATA) *(*cb_err_get)(int create); |
| 231 | void (*cb_err_del)(void); | 227 | void (*cb_err_del)(void); |
| @@ -240,7 +236,7 @@ struct st_ERR_FNS | |||
| 240 | void (*cb_thread_del_item)(const ERR_STATE *); | 236 | void (*cb_thread_del_item)(const ERR_STATE *); |
| 241 | /* Returns the next available error "library" numbers */ | 237 | /* Returns the next available error "library" numbers */ |
| 242 | int (*cb_get_next_lib)(void); | 238 | int (*cb_get_next_lib)(void); |
| 243 | }; | 239 | }; |
| 244 | 240 | ||
| 245 | /* Predeclarations of the "err_defaults" functions */ | 241 | /* Predeclarations of the "err_defaults" functions */ |
| 246 | static LHASH_OF(ERR_STRING_DATA) *int_err_get(int create); | 242 | static LHASH_OF(ERR_STRING_DATA) *int_err_get(int create); |
| @@ -254,9 +250,9 @@ static ERR_STATE *int_thread_get_item(const ERR_STATE *); | |||
| 254 | static ERR_STATE *int_thread_set_item(ERR_STATE *); | 250 | static ERR_STATE *int_thread_set_item(ERR_STATE *); |
| 255 | static void int_thread_del_item(const ERR_STATE *); | 251 | static void int_thread_del_item(const ERR_STATE *); |
| 256 | static int int_err_get_next_lib(void); | 252 | static int int_err_get_next_lib(void); |
| 253 | |||
| 257 | /* The static ERR_FNS table using these defaults functions */ | 254 | /* The static ERR_FNS table using these defaults functions */ |
| 258 | static const ERR_FNS err_defaults = | 255 | static const ERR_FNS err_defaults = { |
| 259 | { | ||
| 260 | int_err_get, | 256 | int_err_get, |
| 261 | int_err_del, | 257 | int_err_del, |
| 262 | int_err_get_item, | 258 | int_err_get_item, |
| @@ -268,7 +264,7 @@ static const ERR_FNS err_defaults = | |||
| 268 | int_thread_set_item, | 264 | int_thread_set_item, |
| 269 | int_thread_del_item, | 265 | int_thread_del_item, |
| 270 | int_err_get_next_lib | 266 | int_err_get_next_lib |
| 271 | }; | 267 | }; |
| 272 | 268 | ||
| 273 | /* The replacable table of ERR_FNS functions we use at run-time */ | 269 | /* The replacable table of ERR_FNS functions we use at run-time */ |
| 274 | static const ERR_FNS *err_fns = NULL; | 270 | static const ERR_FNS *err_fns = NULL; |
| @@ -284,100 +280,105 @@ static const ERR_FNS *err_fns = NULL; | |||
| 284 | static LHASH_OF(ERR_STRING_DATA) *int_error_hash = NULL; | 280 | static LHASH_OF(ERR_STRING_DATA) *int_error_hash = NULL; |
| 285 | static LHASH_OF(ERR_STATE) *int_thread_hash = NULL; | 281 | static LHASH_OF(ERR_STATE) *int_thread_hash = NULL; |
| 286 | static int int_thread_hash_references = 0; | 282 | static int int_thread_hash_references = 0; |
| 287 | static int int_err_library_number= ERR_LIB_USER; | 283 | static int int_err_library_number = ERR_LIB_USER; |
| 288 | 284 | ||
| 289 | /* Internal function that checks whether "err_fns" is set and if not, sets it to | 285 | /* Internal function that checks whether "err_fns" is set and if not, sets it to |
| 290 | * the defaults. */ | 286 | * the defaults. */ |
| 291 | static void err_fns_check(void) | 287 | static void |
| 292 | { | 288 | err_fns_check(void) |
| 293 | if (err_fns) return; | 289 | { |
| 294 | 290 | if (err_fns) | |
| 291 | return; | ||
| 292 | |||
| 295 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | 293 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); |
| 296 | if (!err_fns) | 294 | if (!err_fns) |
| 297 | err_fns = &err_defaults; | 295 | err_fns = &err_defaults; |
| 298 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | 296 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); |
| 299 | } | 297 | } |
| 300 | 298 | ||
| 301 | /* API functions to get or set the underlying ERR functions. */ | 299 | /* API functions to get or set the underlying ERR functions. */ |
| 302 | 300 | ||
| 303 | const ERR_FNS *ERR_get_implementation(void) | 301 | const ERR_FNS * |
| 304 | { | 302 | ERR_get_implementation(void) |
| 303 | { | ||
| 305 | err_fns_check(); | 304 | err_fns_check(); |
| 306 | return err_fns; | 305 | return err_fns; |
| 307 | } | 306 | } |
| 308 | 307 | ||
| 309 | int ERR_set_implementation(const ERR_FNS *fns) | 308 | int |
| 310 | { | 309 | ERR_set_implementation(const ERR_FNS *fns) |
| 310 | { | ||
| 311 | int ret = 0; | 311 | int ret = 0; |
| 312 | 312 | ||
| 313 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | 313 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); |
| 314 | /* It's too late if 'err_fns' is non-NULL. BTW: not much point setting | 314 | /* It's too late if 'err_fns' is non-NULL. BTW: not much point setting |
| 315 | * an error is there?! */ | 315 | * an error is there?! */ |
| 316 | if (!err_fns) | 316 | if (!err_fns) { |
| 317 | { | ||
| 318 | err_fns = fns; | 317 | err_fns = fns; |
| 319 | ret = 1; | 318 | ret = 1; |
| 320 | } | 319 | } |
| 321 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | 320 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); |
| 322 | return ret; | 321 | return ret; |
| 323 | } | 322 | } |
| 324 | 323 | ||
| 325 | /* These are the callbacks provided to "lh_new()" when creating the LHASH tables | 324 | /* These are the callbacks provided to "lh_new()" when creating the LHASH tables |
| 326 | * internal to the "err_defaults" implementation. */ | 325 | * internal to the "err_defaults" implementation. */ |
| 327 | 326 | ||
| 328 | static unsigned long get_error_values(int inc,int top,const char **file,int *line, | 327 | static unsigned long get_error_values(int inc, int top, const char **file, |
| 329 | const char **data,int *flags); | 328 | int *line, const char **data, int *flags); |
| 330 | 329 | ||
| 331 | /* The internal functions used in the "err_defaults" implementation */ | 330 | /* The internal functions used in the "err_defaults" implementation */ |
| 332 | 331 | ||
| 333 | static unsigned long err_string_data_hash(const ERR_STRING_DATA *a) | 332 | static unsigned long |
| 334 | { | 333 | err_string_data_hash(const ERR_STRING_DATA *a) |
| 335 | unsigned long ret,l; | 334 | { |
| 335 | unsigned long ret, l; | ||
| 336 | 336 | ||
| 337 | l=a->error; | 337 | l = a->error; |
| 338 | ret=l^ERR_GET_LIB(l)^ERR_GET_FUNC(l); | 338 | ret = l^ERR_GET_LIB(l)^ERR_GET_FUNC(l); |
| 339 | return(ret^ret%19*13); | 339 | return (ret^ret % 19*13); |
| 340 | } | 340 | } |
| 341 | static IMPLEMENT_LHASH_HASH_FN(err_string_data, ERR_STRING_DATA) | 341 | static IMPLEMENT_LHASH_HASH_FN(err_string_data, ERR_STRING_DATA) |
| 342 | 342 | ||
| 343 | static int err_string_data_cmp(const ERR_STRING_DATA *a, | 343 | static int |
| 344 | const ERR_STRING_DATA *b) | 344 | err_string_data_cmp(const ERR_STRING_DATA *a, const ERR_STRING_DATA *b) |
| 345 | { | 345 | { |
| 346 | return (int)(a->error - b->error); | 346 | return (int)(a->error - b->error); |
| 347 | } | 347 | } |
| 348 | static IMPLEMENT_LHASH_COMP_FN(err_string_data, ERR_STRING_DATA) | 348 | static IMPLEMENT_LHASH_COMP_FN(err_string_data, ERR_STRING_DATA) |
| 349 | 349 | ||
| 350 | static LHASH_OF(ERR_STRING_DATA) *int_err_get(int create) | 350 | static |
| 351 | { | 351 | LHASH_OF(ERR_STRING_DATA) *int_err_get(int create) |
| 352 | { | ||
| 352 | LHASH_OF(ERR_STRING_DATA) *ret = NULL; | 353 | LHASH_OF(ERR_STRING_DATA) *ret = NULL; |
| 353 | 354 | ||
| 354 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | 355 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); |
| 355 | if (!int_error_hash && create) | 356 | if (!int_error_hash && create) { |
| 356 | { | ||
| 357 | CRYPTO_push_info("int_err_get (err.c)"); | 357 | CRYPTO_push_info("int_err_get (err.c)"); |
| 358 | int_error_hash = lh_ERR_STRING_DATA_new(); | 358 | int_error_hash = lh_ERR_STRING_DATA_new(); |
| 359 | CRYPTO_pop_info(); | 359 | CRYPTO_pop_info(); |
| 360 | } | 360 | } |
| 361 | if (int_error_hash) | 361 | if (int_error_hash) |
| 362 | ret = int_error_hash; | 362 | ret = int_error_hash; |
| 363 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | 363 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); |
| 364 | 364 | ||
| 365 | return ret; | 365 | return ret; |
| 366 | } | 366 | } |
| 367 | 367 | ||
| 368 | static void int_err_del(void) | 368 | static void |
| 369 | { | 369 | int_err_del(void) |
| 370 | { | ||
| 370 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | 371 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); |
| 371 | if (int_error_hash) | 372 | if (int_error_hash) { |
| 372 | { | ||
| 373 | lh_ERR_STRING_DATA_free(int_error_hash); | 373 | lh_ERR_STRING_DATA_free(int_error_hash); |
| 374 | int_error_hash = NULL; | 374 | int_error_hash = NULL; |
| 375 | } | ||
| 376 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | ||
| 377 | } | 375 | } |
| 376 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | ||
| 377 | } | ||
| 378 | 378 | ||
| 379 | static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *d) | 379 | static ERR_STRING_DATA * |
| 380 | { | 380 | int_err_get_item(const ERR_STRING_DATA *d) |
| 381 | { | ||
| 381 | ERR_STRING_DATA *p; | 382 | ERR_STRING_DATA *p; |
| 382 | LHASH_OF(ERR_STRING_DATA) *hash; | 383 | LHASH_OF(ERR_STRING_DATA) *hash; |
| 383 | 384 | ||
| @@ -391,10 +392,11 @@ static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *d) | |||
| 391 | CRYPTO_r_unlock(CRYPTO_LOCK_ERR); | 392 | CRYPTO_r_unlock(CRYPTO_LOCK_ERR); |
| 392 | 393 | ||
| 393 | return p; | 394 | return p; |
| 394 | } | 395 | } |
| 395 | 396 | ||
| 396 | static ERR_STRING_DATA *int_err_set_item(ERR_STRING_DATA *d) | 397 | static ERR_STRING_DATA * |
| 397 | { | 398 | int_err_set_item(ERR_STRING_DATA *d) |
| 399 | { | ||
| 398 | ERR_STRING_DATA *p; | 400 | ERR_STRING_DATA *p; |
| 399 | LHASH_OF(ERR_STRING_DATA) *hash; | 401 | LHASH_OF(ERR_STRING_DATA) *hash; |
| 400 | 402 | ||
| @@ -408,10 +410,11 @@ static ERR_STRING_DATA *int_err_set_item(ERR_STRING_DATA *d) | |||
| 408 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | 410 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); |
| 409 | 411 | ||
| 410 | return p; | 412 | return p; |
| 411 | } | 413 | } |
| 412 | 414 | ||
| 413 | static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *d) | 415 | static ERR_STRING_DATA * |
| 414 | { | 416 | int_err_del_item(ERR_STRING_DATA *d) |
| 417 | { | ||
| 415 | ERR_STRING_DATA *p; | 418 | ERR_STRING_DATA *p; |
| 416 | LHASH_OF(ERR_STRING_DATA) *hash; | 419 | LHASH_OF(ERR_STRING_DATA) *hash; |
| 417 | 420 | ||
| @@ -425,55 +428,59 @@ static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *d) | |||
| 425 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | 428 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); |
| 426 | 429 | ||
| 427 | return p; | 430 | return p; |
| 428 | } | 431 | } |
| 429 | 432 | ||
| 430 | static unsigned long err_state_hash(const ERR_STATE *a) | 433 | static unsigned long |
| 431 | { | 434 | err_state_hash(const ERR_STATE *a) |
| 435 | { | ||
| 432 | return CRYPTO_THREADID_hash(&a->tid) * 13; | 436 | return CRYPTO_THREADID_hash(&a->tid) * 13; |
| 433 | } | 437 | } |
| 434 | static IMPLEMENT_LHASH_HASH_FN(err_state, ERR_STATE) | 438 | static IMPLEMENT_LHASH_HASH_FN(err_state, ERR_STATE) |
| 435 | 439 | ||
| 436 | static int err_state_cmp(const ERR_STATE *a, const ERR_STATE *b) | 440 | static int |
| 437 | { | 441 | err_state_cmp(const ERR_STATE *a, const ERR_STATE *b) |
| 442 | { | ||
| 438 | return CRYPTO_THREADID_cmp(&a->tid, &b->tid); | 443 | return CRYPTO_THREADID_cmp(&a->tid, &b->tid); |
| 439 | } | 444 | } |
| 440 | static IMPLEMENT_LHASH_COMP_FN(err_state, ERR_STATE) | 445 | static IMPLEMENT_LHASH_COMP_FN(err_state, ERR_STATE) |
| 441 | 446 | ||
| 442 | static LHASH_OF(ERR_STATE) *int_thread_get(int create) | 447 | static |
| 443 | { | 448 | LHASH_OF(ERR_STATE) *int_thread_get(int create) |
| 449 | { | ||
| 444 | LHASH_OF(ERR_STATE) *ret = NULL; | 450 | LHASH_OF(ERR_STATE) *ret = NULL; |
| 445 | 451 | ||
| 446 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | 452 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); |
| 447 | if (!int_thread_hash && create) | 453 | if (!int_thread_hash && create) { |
| 448 | { | ||
| 449 | CRYPTO_push_info("int_thread_get (err.c)"); | 454 | CRYPTO_push_info("int_thread_get (err.c)"); |
| 450 | int_thread_hash = lh_ERR_STATE_new(); | 455 | int_thread_hash = lh_ERR_STATE_new(); |
| 451 | CRYPTO_pop_info(); | 456 | CRYPTO_pop_info(); |
| 452 | } | 457 | } |
| 453 | if (int_thread_hash) | 458 | if (int_thread_hash) { |
| 454 | { | ||
| 455 | int_thread_hash_references++; | 459 | int_thread_hash_references++; |
| 456 | ret = int_thread_hash; | 460 | ret = int_thread_hash; |
| 457 | } | 461 | } |
| 458 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | 462 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); |
| 459 | return ret; | 463 | return ret; |
| 460 | } | 464 | } |
| 461 | 465 | ||
| 462 | static void int_thread_release(LHASH_OF(ERR_STATE) **hash) | 466 | static void |
| 463 | { | 467 | int_thread_release(LHASH_OF(ERR_STATE) **hash) |
| 468 | { | ||
| 464 | int i; | 469 | int i; |
| 465 | 470 | ||
| 466 | if (hash == NULL || *hash == NULL) | 471 | if (hash == NULL || *hash == NULL) |
| 467 | return; | 472 | return; |
| 468 | 473 | ||
| 469 | i = CRYPTO_add(&int_thread_hash_references, -1, CRYPTO_LOCK_ERR); | 474 | i = CRYPTO_add(&int_thread_hash_references, -1, CRYPTO_LOCK_ERR); |
| 470 | if (i > 0) return; | 475 | if (i > 0) |
| 476 | return; | ||
| 471 | 477 | ||
| 472 | *hash = NULL; | 478 | *hash = NULL; |
| 473 | } | 479 | } |
| 474 | 480 | ||
| 475 | static ERR_STATE *int_thread_get_item(const ERR_STATE *d) | 481 | static ERR_STATE * |
| 476 | { | 482 | int_thread_get_item(const ERR_STATE *d) |
| 483 | { | ||
| 477 | ERR_STATE *p; | 484 | ERR_STATE *p; |
| 478 | LHASH_OF(ERR_STATE) *hash; | 485 | LHASH_OF(ERR_STATE) *hash; |
| 479 | 486 | ||
| @@ -488,10 +495,11 @@ static ERR_STATE *int_thread_get_item(const ERR_STATE *d) | |||
| 488 | 495 | ||
| 489 | ERRFN(thread_release)(&hash); | 496 | ERRFN(thread_release)(&hash); |
| 490 | return p; | 497 | return p; |
| 491 | } | 498 | } |
| 492 | 499 | ||
| 493 | static ERR_STATE *int_thread_set_item(ERR_STATE *d) | 500 | static ERR_STATE * |
| 494 | { | 501 | int_thread_set_item(ERR_STATE *d) |
| 502 | { | ||
| 495 | ERR_STATE *p; | 503 | ERR_STATE *p; |
| 496 | LHASH_OF(ERR_STATE) *hash; | 504 | LHASH_OF(ERR_STATE) *hash; |
| 497 | 505 | ||
| @@ -506,10 +514,11 @@ static ERR_STATE *int_thread_set_item(ERR_STATE *d) | |||
| 506 | 514 | ||
| 507 | ERRFN(thread_release)(&hash); | 515 | ERRFN(thread_release)(&hash); |
| 508 | return p; | 516 | return p; |
| 509 | } | 517 | } |
| 510 | 518 | ||
| 511 | static void int_thread_del_item(const ERR_STATE *d) | 519 | static void |
| 512 | { | 520 | int_thread_del_item(const ERR_STATE *d) |
| 521 | { | ||
| 513 | ERR_STATE *p; | 522 | ERR_STATE *p; |
| 514 | LHASH_OF(ERR_STATE) *hash; | 523 | LHASH_OF(ERR_STATE) *hash; |
| 515 | 524 | ||
| @@ -521,21 +530,21 @@ static void int_thread_del_item(const ERR_STATE *d) | |||
| 521 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | 530 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); |
| 522 | p = lh_ERR_STATE_delete(hash, d); | 531 | p = lh_ERR_STATE_delete(hash, d); |
| 523 | /* make sure we don't leak memory */ | 532 | /* make sure we don't leak memory */ |
| 524 | if (int_thread_hash_references == 1 | 533 | if (int_thread_hash_references == 1 && |
| 525 | && int_thread_hash && lh_ERR_STATE_num_items(int_thread_hash) == 0) | 534 | int_thread_hash && lh_ERR_STATE_num_items(int_thread_hash) == 0) { |
| 526 | { | ||
| 527 | lh_ERR_STATE_free(int_thread_hash); | 535 | lh_ERR_STATE_free(int_thread_hash); |
| 528 | int_thread_hash = NULL; | 536 | int_thread_hash = NULL; |
| 529 | } | 537 | } |
| 530 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | 538 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); |
| 531 | 539 | ||
| 532 | ERRFN(thread_release)(&hash); | 540 | ERRFN(thread_release)(&hash); |
| 533 | if (p) | 541 | if (p) |
| 534 | ERR_STATE_free(p); | 542 | ERR_STATE_free(p); |
| 535 | } | 543 | } |
| 536 | 544 | ||
| 537 | static int int_err_get_next_lib(void) | 545 | static int |
| 538 | { | 546 | int_err_get_next_lib(void) |
| 547 | { | ||
| 539 | int ret; | 548 | int ret; |
| 540 | 549 | ||
| 541 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | 550 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); |
| @@ -543,7 +552,7 @@ static int int_err_get_next_lib(void) | |||
| 543 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | 552 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); |
| 544 | 553 | ||
| 545 | return ret; | 554 | return ret; |
| 546 | } | 555 | } |
| 547 | 556 | ||
| 548 | 557 | ||
| 549 | #ifndef OPENSSL_NO_ERR | 558 | #ifndef OPENSSL_NO_ERR |
| @@ -560,54 +569,51 @@ static ERR_STRING_DATA SYS_str_reasons[NUM_SYS_STR_REASONS + 1]; | |||
| 560 | * will be returned for SYSerr(), which always gets an errno | 569 | * will be returned for SYSerr(), which always gets an errno |
| 561 | * value and never one of those 'standard' reason codes. */ | 570 | * value and never one of those 'standard' reason codes. */ |
| 562 | 571 | ||
| 563 | static void build_SYS_str_reasons(void) | 572 | static void |
| 564 | { | 573 | build_SYS_str_reasons(void) |
| 574 | { | ||
| 565 | /* malloc cannot be used here, use static storage instead */ | 575 | /* malloc cannot be used here, use static storage instead */ |
| 566 | static char strerror_tab[NUM_SYS_STR_REASONS][LEN_SYS_STR_REASON]; | 576 | static char strerror_tab[NUM_SYS_STR_REASONS][LEN_SYS_STR_REASON]; |
| 567 | int i; | 577 | int i; |
| 568 | static int init = 1; | 578 | static int init = 1; |
| 569 | 579 | ||
| 570 | CRYPTO_r_lock(CRYPTO_LOCK_ERR); | 580 | CRYPTO_r_lock(CRYPTO_LOCK_ERR); |
| 571 | if (!init) | 581 | if (!init) { |
| 572 | { | ||
| 573 | CRYPTO_r_unlock(CRYPTO_LOCK_ERR); | 582 | CRYPTO_r_unlock(CRYPTO_LOCK_ERR); |
| 574 | return; | 583 | return; |
| 575 | } | 584 | } |
| 576 | 585 | ||
| 577 | CRYPTO_r_unlock(CRYPTO_LOCK_ERR); | 586 | CRYPTO_r_unlock(CRYPTO_LOCK_ERR); |
| 578 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | 587 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); |
| 579 | if (!init) | 588 | if (!init) { |
| 580 | { | ||
| 581 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | 589 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); |
| 582 | return; | 590 | return; |
| 583 | } | 591 | } |
| 584 | 592 | ||
| 585 | for (i = 1; i <= NUM_SYS_STR_REASONS; i++) | 593 | for (i = 1; i <= NUM_SYS_STR_REASONS; i++) { |
| 586 | { | ||
| 587 | ERR_STRING_DATA *str = &SYS_str_reasons[i - 1]; | 594 | ERR_STRING_DATA *str = &SYS_str_reasons[i - 1]; |
| 588 | 595 | ||
| 589 | str->error = (unsigned long)i; | 596 | str->error = (unsigned long)i; |
| 590 | if (str->string == NULL) | 597 | if (str->string == NULL) { |
| 591 | { | 598 | char (*dest)[LEN_SYS_STR_REASON] = |
| 592 | char (*dest)[LEN_SYS_STR_REASON] = &(strerror_tab[i - 1]); | 599 | &(strerror_tab[i - 1]); |
| 593 | char *src = strerror(i); | 600 | char *src = strerror(i); |
| 594 | if (src != NULL) | 601 | if (src != NULL) { |
| 595 | { | ||
| 596 | strlcpy(*dest, src, sizeof *dest); | 602 | strlcpy(*dest, src, sizeof *dest); |
| 597 | str->string = *dest; | 603 | str->string = *dest; |
| 598 | } | ||
| 599 | } | 604 | } |
| 605 | } | ||
| 600 | if (str->string == NULL) | 606 | if (str->string == NULL) |
| 601 | str->string = "unknown"; | 607 | str->string = "unknown"; |
| 602 | } | 608 | } |
| 603 | 609 | ||
| 604 | /* Now we still have SYS_str_reasons[NUM_SYS_STR_REASONS] = {0, NULL}, | 610 | /* Now we still have SYS_str_reasons[NUM_SYS_STR_REASONS] = {0, NULL}, |
| 605 | * as required by ERR_load_strings. */ | 611 | * as required by ERR_load_strings. */ |
| 606 | 612 | ||
| 607 | init = 0; | 613 | init = 0; |
| 608 | 614 | ||
| 609 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | 615 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); |
| 610 | } | 616 | } |
| 611 | #endif | 617 | #endif |
| 612 | 618 | ||
| 613 | #define err_clear_data(p,i) \ | 619 | #define err_clear_data(p,i) \ |
| @@ -630,216 +636,232 @@ static void build_SYS_str_reasons(void) | |||
| 630 | (p)->err_line[i]= -1; \ | 636 | (p)->err_line[i]= -1; \ |
| 631 | } while(0) | 637 | } while(0) |
| 632 | 638 | ||
| 633 | static void ERR_STATE_free(ERR_STATE *s) | 639 | static void |
| 634 | { | 640 | ERR_STATE_free(ERR_STATE *s) |
| 641 | { | ||
| 635 | int i; | 642 | int i; |
| 636 | 643 | ||
| 637 | if (s == NULL) | 644 | if (s == NULL) |
| 638 | return; | 645 | return; |
| 639 | 646 | ||
| 640 | for (i=0; i<ERR_NUM_ERRORS; i++) | 647 | for (i = 0; i < ERR_NUM_ERRORS; i++) { |
| 641 | { | 648 | err_clear_data(s, i); |
| 642 | err_clear_data(s,i); | ||
| 643 | } | ||
| 644 | free(s); | ||
| 645 | } | 649 | } |
| 650 | free(s); | ||
| 651 | } | ||
| 646 | 652 | ||
| 647 | void ERR_load_ERR_strings(void) | 653 | void |
| 648 | { | 654 | ERR_load_ERR_strings(void) |
| 655 | { | ||
| 649 | err_fns_check(); | 656 | err_fns_check(); |
| 650 | #ifndef OPENSSL_NO_ERR | 657 | #ifndef OPENSSL_NO_ERR |
| 651 | err_load_strings(0,ERR_str_libraries); | 658 | err_load_strings(0, ERR_str_libraries); |
| 652 | err_load_strings(0,ERR_str_reasons); | 659 | err_load_strings(0, ERR_str_reasons); |
| 653 | err_load_strings(ERR_LIB_SYS,ERR_str_functs); | 660 | err_load_strings(ERR_LIB_SYS, ERR_str_functs); |
| 654 | build_SYS_str_reasons(); | 661 | build_SYS_str_reasons(); |
| 655 | err_load_strings(ERR_LIB_SYS,SYS_str_reasons); | 662 | err_load_strings(ERR_LIB_SYS, SYS_str_reasons); |
| 656 | #endif | 663 | #endif |
| 657 | } | 664 | } |
| 658 | 665 | ||
| 659 | static void err_load_strings(int lib, ERR_STRING_DATA *str) | 666 | static void |
| 660 | { | 667 | err_load_strings(int lib, ERR_STRING_DATA *str) |
| 661 | while (str->error) | 668 | { |
| 662 | { | 669 | while (str->error) { |
| 663 | if (lib) | 670 | if (lib) |
| 664 | str->error|=ERR_PACK(lib,0,0); | 671 | str->error |= ERR_PACK(lib, 0, 0); |
| 665 | ERRFN(err_set_item)(str); | 672 | ERRFN(err_set_item)(str); |
| 666 | str++; | 673 | str++; |
| 667 | } | ||
| 668 | } | 674 | } |
| 675 | } | ||
| 669 | 676 | ||
| 670 | void ERR_load_strings(int lib, ERR_STRING_DATA *str) | 677 | void |
| 671 | { | 678 | ERR_load_strings(int lib, ERR_STRING_DATA *str) |
| 679 | { | ||
| 672 | ERR_load_ERR_strings(); | 680 | ERR_load_ERR_strings(); |
| 673 | err_load_strings(lib, str); | 681 | err_load_strings(lib, str); |
| 674 | } | 682 | } |
| 675 | 683 | ||
| 676 | void ERR_unload_strings(int lib, ERR_STRING_DATA *str) | 684 | void |
| 677 | { | 685 | ERR_unload_strings(int lib, ERR_STRING_DATA *str) |
| 678 | while (str->error) | 686 | { |
| 679 | { | 687 | while (str->error) { |
| 680 | if (lib) | 688 | if (lib) |
| 681 | str->error|=ERR_PACK(lib,0,0); | 689 | str->error |= ERR_PACK(lib, 0, 0); |
| 682 | ERRFN(err_del_item)(str); | 690 | ERRFN(err_del_item)(str); |
| 683 | str++; | 691 | str++; |
| 684 | } | ||
| 685 | } | 692 | } |
| 693 | } | ||
| 686 | 694 | ||
| 687 | void ERR_free_strings(void) | 695 | void |
| 688 | { | 696 | ERR_free_strings(void) |
| 697 | { | ||
| 689 | err_fns_check(); | 698 | err_fns_check(); |
| 690 | ERRFN(err_del)(); | 699 | ERRFN(err_del)(); |
| 691 | } | 700 | } |
| 692 | 701 | ||
| 693 | /********************************************************/ | 702 | /********************************************************/ |
| 694 | 703 | ||
| 695 | void ERR_put_error(int lib, int func, int reason, const char *file, | 704 | void |
| 696 | int line) | 705 | ERR_put_error(int lib, int func, int reason, const char *file, int line) |
| 697 | { | 706 | { |
| 698 | ERR_STATE *es; | 707 | ERR_STATE *es; |
| 699 | 708 | ||
| 700 | es=ERR_get_state(); | 709 | es = ERR_get_state(); |
| 701 | 710 | ||
| 702 | es->top=(es->top+1)%ERR_NUM_ERRORS; | 711 | es->top = (es->top + 1) % ERR_NUM_ERRORS; |
| 703 | if (es->top == es->bottom) | 712 | if (es->top == es->bottom) |
| 704 | es->bottom=(es->bottom+1)%ERR_NUM_ERRORS; | 713 | es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS; |
| 705 | es->err_flags[es->top]=0; | 714 | es->err_flags[es->top] = 0; |
| 706 | es->err_buffer[es->top]=ERR_PACK(lib,func,reason); | 715 | es->err_buffer[es->top] = ERR_PACK(lib, func, reason); |
| 707 | es->err_file[es->top]=file; | 716 | es->err_file[es->top] = file; |
| 708 | es->err_line[es->top]=line; | 717 | es->err_line[es->top] = line; |
| 709 | err_clear_data(es,es->top); | 718 | err_clear_data(es, es->top); |
| 710 | } | 719 | } |
| 711 | 720 | ||
| 712 | void ERR_clear_error(void) | 721 | void |
| 713 | { | 722 | ERR_clear_error(void) |
| 723 | { | ||
| 714 | int i; | 724 | int i; |
| 715 | ERR_STATE *es; | 725 | ERR_STATE *es; |
| 716 | 726 | ||
| 717 | es=ERR_get_state(); | 727 | es = ERR_get_state(); |
| 718 | 728 | ||
| 719 | for (i=0; i<ERR_NUM_ERRORS; i++) | 729 | for (i = 0; i < ERR_NUM_ERRORS; i++) { |
| 720 | { | 730 | err_clear(es, i); |
| 721 | err_clear(es,i); | ||
| 722 | } | ||
| 723 | es->top=es->bottom=0; | ||
| 724 | } | 731 | } |
| 732 | es->top = es->bottom = 0; | ||
| 733 | } | ||
| 725 | 734 | ||
| 726 | 735 | ||
| 727 | unsigned long ERR_get_error(void) | 736 | unsigned long ERR_get_error(void) |
| 728 | { return(get_error_values(1,0,NULL,NULL,NULL,NULL)); } | 737 | { |
| 738 | return (get_error_values(1, 0,NULL, NULL, NULL, NULL)); | ||
| 739 | } | ||
| 729 | 740 | ||
| 730 | unsigned long ERR_get_error_line(const char **file, | 741 | unsigned long ERR_get_error_line(const char **file, int *line) |
| 731 | int *line) | 742 | { |
| 732 | { return(get_error_values(1,0,file,line,NULL,NULL)); } | 743 | return (get_error_values(1, 0,file, line, NULL, NULL)); |
| 744 | } | ||
| 733 | 745 | ||
| 734 | unsigned long ERR_get_error_line_data(const char **file, int *line, | 746 | unsigned long ERR_get_error_line_data(const char **file, int *line, |
| 735 | const char **data, int *flags) | 747 | const char **data, int *flags) |
| 736 | { return(get_error_values(1,0,file,line,data,flags)); } | 748 | { |
| 749 | return (get_error_values(1, 0,file, line, data, flags)); | ||
| 750 | } | ||
| 737 | 751 | ||
| 738 | 752 | ||
| 739 | unsigned long ERR_peek_error(void) | 753 | unsigned long ERR_peek_error(void) |
| 740 | { return(get_error_values(0,0,NULL,NULL,NULL,NULL)); } | 754 | { |
| 755 | return (get_error_values(0, 0,NULL, NULL, NULL, NULL)); | ||
| 756 | } | ||
| 741 | 757 | ||
| 742 | unsigned long ERR_peek_error_line(const char **file, int *line) | 758 | unsigned long ERR_peek_error_line(const char **file, int *line) |
| 743 | { return(get_error_values(0,0,file,line,NULL,NULL)); } | 759 | { |
| 760 | return (get_error_values(0, 0,file, line, NULL, NULL)); | ||
| 761 | } | ||
| 744 | 762 | ||
| 745 | unsigned long ERR_peek_error_line_data(const char **file, int *line, | 763 | unsigned long ERR_peek_error_line_data(const char **file, int *line, |
| 746 | const char **data, int *flags) | 764 | const char **data, int *flags) |
| 747 | { return(get_error_values(0,0,file,line,data,flags)); } | 765 | { |
| 748 | 766 | return (get_error_values(0, 0,file, line, data, flags)); | |
| 767 | } | ||
| 749 | 768 | ||
| 750 | unsigned long ERR_peek_last_error(void) | 769 | unsigned long ERR_peek_last_error(void) |
| 751 | { return(get_error_values(0,1,NULL,NULL,NULL,NULL)); } | 770 | { |
| 771 | return (get_error_values(0, 1,NULL, NULL, NULL, NULL)); | ||
| 772 | } | ||
| 752 | 773 | ||
| 753 | unsigned long ERR_peek_last_error_line(const char **file, int *line) | 774 | unsigned long ERR_peek_last_error_line(const char **file, int *line) |
| 754 | { return(get_error_values(0,1,file,line,NULL,NULL)); } | 775 | { |
| 776 | return (get_error_values(0, 1,file, line, NULL, NULL)); | ||
| 777 | } | ||
| 755 | 778 | ||
| 756 | unsigned long ERR_peek_last_error_line_data(const char **file, int *line, | 779 | unsigned long ERR_peek_last_error_line_data(const char **file, int *line, |
| 757 | const char **data, int *flags) | 780 | const char **data, int *flags) |
| 758 | { return(get_error_values(0,1,file,line,data,flags)); } | 781 | { |
| 759 | 782 | return (get_error_values(0, 1,file, line, data, flags)); | |
| 760 | 783 | } | |
| 761 | static unsigned long get_error_values(int inc, int top, const char **file, int *line, | 784 | |
| 762 | const char **data, int *flags) | 785 | static unsigned |
| 763 | { | 786 | long get_error_values(int inc, int top, const char **file, int *line, |
| 764 | int i=0; | 787 | const char **data, int *flags) |
| 788 | { | ||
| 789 | int i = 0; | ||
| 765 | ERR_STATE *es; | 790 | ERR_STATE *es; |
| 766 | unsigned long ret; | 791 | unsigned long ret; |
| 767 | 792 | ||
| 768 | es=ERR_get_state(); | 793 | es = ERR_get_state(); |
| 794 | |||
| 795 | if (inc && top) { | ||
| 796 | if (file) | ||
| 797 | *file = ""; | ||
| 798 | if (line) | ||
| 799 | *line = 0; | ||
| 800 | if (data) | ||
| 801 | *data = ""; | ||
| 802 | if (flags) | ||
| 803 | *flags = 0; | ||
| 769 | 804 | ||
| 770 | if (inc && top) | ||
| 771 | { | ||
| 772 | if (file) *file = ""; | ||
| 773 | if (line) *line = 0; | ||
| 774 | if (data) *data = ""; | ||
| 775 | if (flags) *flags = 0; | ||
| 776 | |||
| 777 | return ERR_R_INTERNAL_ERROR; | 805 | return ERR_R_INTERNAL_ERROR; |
| 778 | } | 806 | } |
| 779 | 807 | ||
| 780 | if (es->bottom == es->top) return 0; | 808 | if (es->bottom == es->top) |
| 809 | return 0; | ||
| 781 | if (top) | 810 | if (top) |
| 782 | i=es->top; /* last error */ | 811 | i = es->top; /* last error */ |
| 783 | else | 812 | else |
| 784 | i=(es->bottom+1)%ERR_NUM_ERRORS; /* first error */ | 813 | i = (es->bottom + 1) % ERR_NUM_ERRORS; /* first error */ |
| 785 | 814 | ||
| 786 | ret=es->err_buffer[i]; | 815 | ret = es->err_buffer[i]; |
| 787 | if (inc) | 816 | if (inc) { |
| 788 | { | 817 | es->bottom = i; |
| 789 | es->bottom=i; | 818 | es->err_buffer[i] = 0; |
| 790 | es->err_buffer[i]=0; | 819 | } |
| 791 | } | ||
| 792 | 820 | ||
| 793 | if ((file != NULL) && (line != NULL)) | 821 | if ((file != NULL) && (line != NULL)) { |
| 794 | { | 822 | if (es->err_file[i] == NULL) { |
| 795 | if (es->err_file[i] == NULL) | 823 | *file = "NA"; |
| 796 | { | 824 | if (line != NULL) |
| 797 | *file="NA"; | 825 | *line = 0; |
| 798 | if (line != NULL) *line=0; | 826 | } else { |
| 799 | } | 827 | *file = es->err_file[i]; |
| 800 | else | 828 | if (line != NULL) |
| 801 | { | 829 | *line = es->err_line[i]; |
| 802 | *file=es->err_file[i]; | ||
| 803 | if (line != NULL) *line=es->err_line[i]; | ||
| 804 | } | ||
| 805 | } | 830 | } |
| 831 | } | ||
| 806 | 832 | ||
| 807 | if (data == NULL) | 833 | if (data == NULL) { |
| 808 | { | 834 | if (inc) { |
| 809 | if (inc) | ||
| 810 | { | ||
| 811 | err_clear_data(es, i); | 835 | err_clear_data(es, i); |
| 812 | } | ||
| 813 | } | 836 | } |
| 814 | else | 837 | } else { |
| 815 | { | 838 | if (es->err_data[i] == NULL) { |
| 816 | if (es->err_data[i] == NULL) | 839 | *data = ""; |
| 817 | { | 840 | if (flags != NULL) |
| 818 | *data=""; | 841 | *flags = 0; |
| 819 | if (flags != NULL) *flags=0; | 842 | } else { |
| 820 | } | 843 | *data = es->err_data[i]; |
| 821 | else | 844 | if (flags != NULL) |
| 822 | { | 845 | *flags = es->err_data_flags[i]; |
| 823 | *data=es->err_data[i]; | ||
| 824 | if (flags != NULL) *flags=es->err_data_flags[i]; | ||
| 825 | } | ||
| 826 | } | 846 | } |
| 827 | return ret; | ||
| 828 | } | 847 | } |
| 848 | return ret; | ||
| 849 | } | ||
| 829 | 850 | ||
| 830 | void ERR_error_string_n(unsigned long e, char *buf, size_t len) | 851 | void |
| 831 | { | 852 | ERR_error_string_n(unsigned long e, char *buf, size_t len) |
| 853 | { | ||
| 832 | char lsbuf[30], fsbuf[30], rsbuf[30]; | 854 | char lsbuf[30], fsbuf[30], rsbuf[30]; |
| 833 | const char *ls,*fs,*rs; | 855 | const char *ls, *fs, *rs; |
| 834 | int l, f, r, ret; | 856 | int l, f, r, ret; |
| 835 | 857 | ||
| 836 | l=ERR_GET_LIB(e); | 858 | l = ERR_GET_LIB(e); |
| 837 | f=ERR_GET_FUNC(e); | 859 | f = ERR_GET_FUNC(e); |
| 838 | r=ERR_GET_REASON(e); | 860 | r = ERR_GET_REASON(e); |
| 839 | 861 | ||
| 840 | ls=ERR_lib_error_string(e); | 862 | ls = ERR_lib_error_string(e); |
| 841 | fs=ERR_func_error_string(e); | 863 | fs = ERR_func_error_string(e); |
| 842 | rs=ERR_reason_error_string(e); | 864 | rs = ERR_reason_error_string(e); |
| 843 | 865 | ||
| 844 | if (ls == NULL) { | 866 | if (ls == NULL) { |
| 845 | (void) snprintf(lsbuf, sizeof(lsbuf), "lib(%d)", l); | 867 | (void) snprintf(lsbuf, sizeof(lsbuf), "lib(%d)", l); |
| @@ -857,108 +879,112 @@ void ERR_error_string_n(unsigned long e, char *buf, size_t len) | |||
| 857 | ret = snprintf(buf, len, "error:%08lX:%s:%s:%s", e, ls, fs, rs); | 879 | ret = snprintf(buf, len, "error:%08lX:%s:%s:%s", e, ls, fs, rs); |
| 858 | if (ret == -1) | 880 | if (ret == -1) |
| 859 | return; /* can't happen, and can't do better if it does */ | 881 | return; /* can't happen, and can't do better if it does */ |
| 860 | if (ret >= len) | 882 | if (ret >= len) { |
| 861 | { | 883 | /* output may be truncated; make sure we always have 5 |
| 862 | /* output may be truncated; make sure we always have 5 | ||
| 863 | * colon-separated fields, i.e. 4 colons ... */ | 884 | * colon-separated fields, i.e. 4 colons ... */ |
| 864 | #define NUM_COLONS 4 | 885 | #define NUM_COLONS 4 |
| 865 | if (len > NUM_COLONS) /* ... if possible */ | 886 | if (len > NUM_COLONS) /* ... if possible */ |
| 866 | { | 887 | { |
| 867 | int i; | 888 | int i; |
| 868 | char *s = buf; | 889 | char *s = buf; |
| 869 | 890 | ||
| 870 | for (i = 0; i < NUM_COLONS; i++) | 891 | for (i = 0; i < NUM_COLONS; i++) { |
| 871 | { | ||
| 872 | char *colon = strchr(s, ':'); | 892 | char *colon = strchr(s, ':'); |
| 873 | if (colon == NULL || colon > &buf[len-1] - NUM_COLONS + i) | 893 | if (colon == NULL || |
| 874 | { | 894 | colon > &buf[len - 1] - NUM_COLONS + i) { |
| 875 | /* set colon no. i at last possible position | 895 | /* set colon no. i at last possible position |
| 876 | * (buf[len-1] is the terminating 0)*/ | 896 | * (buf[len-1] is the terminating 0)*/ |
| 877 | colon = &buf[len-1] - NUM_COLONS + i; | 897 | colon = &buf[len - 1] - NUM_COLONS + i; |
| 878 | *colon = ':'; | 898 | *colon = ':'; |
| 879 | } | ||
| 880 | s = colon + 1; | ||
| 881 | } | 899 | } |
| 900 | s = colon + 1; | ||
| 882 | } | 901 | } |
| 883 | } | 902 | } |
| 884 | } | 903 | } |
| 904 | } | ||
| 885 | 905 | ||
| 886 | /* BAD for multi-threading: uses a local buffer if ret == NULL */ | 906 | /* BAD for multi-threading: uses a local buffer if ret == NULL */ |
| 887 | /* ERR_error_string_n should be used instead for ret != NULL | 907 | /* ERR_error_string_n should be used instead for ret != NULL |
| 888 | * as ERR_error_string cannot know how large the buffer is */ | 908 | * as ERR_error_string cannot know how large the buffer is */ |
| 889 | char *ERR_error_string(unsigned long e, char *ret) | 909 | char * |
| 890 | { | 910 | ERR_error_string(unsigned long e, char *ret) |
| 911 | { | ||
| 891 | static char buf[256]; | 912 | static char buf[256]; |
| 892 | 913 | ||
| 893 | if (ret == NULL) ret=buf; | 914 | if (ret == NULL) |
| 915 | ret = buf; | ||
| 894 | ERR_error_string_n(e, ret, 256); | 916 | ERR_error_string_n(e, ret, 256); |
| 895 | 917 | ||
| 896 | return ret; | 918 | return ret; |
| 897 | } | 919 | } |
| 898 | 920 | ||
| 899 | LHASH_OF(ERR_STRING_DATA) *ERR_get_string_table(void) | 921 | LHASH_OF(ERR_STRING_DATA) *ERR_get_string_table(void) |
| 900 | { | 922 | { |
| 901 | err_fns_check(); | 923 | err_fns_check(); |
| 902 | return ERRFN(err_get)(0); | 924 | return ERRFN(err_get)(0); |
| 903 | } | 925 | } |
| 904 | 926 | ||
| 905 | LHASH_OF(ERR_STATE) *ERR_get_err_state_table(void) | 927 | LHASH_OF(ERR_STATE) *ERR_get_err_state_table(void) |
| 906 | { | 928 | { |
| 907 | err_fns_check(); | 929 | err_fns_check(); |
| 908 | return ERRFN(thread_get)(0); | 930 | return ERRFN(thread_get)(0); |
| 909 | } | 931 | } |
| 910 | 932 | ||
| 911 | void ERR_release_err_state_table(LHASH_OF(ERR_STATE) **hash) | 933 | void |
| 912 | { | 934 | ERR_release_err_state_table(LHASH_OF(ERR_STATE) **hash) |
| 935 | { | ||
| 913 | err_fns_check(); | 936 | err_fns_check(); |
| 914 | ERRFN(thread_release)(hash); | 937 | ERRFN(thread_release)(hash); |
| 915 | } | 938 | } |
| 916 | 939 | ||
| 917 | const char *ERR_lib_error_string(unsigned long e) | 940 | const char * |
| 918 | { | 941 | ERR_lib_error_string(unsigned long e) |
| 919 | ERR_STRING_DATA d,*p; | 942 | { |
| 943 | ERR_STRING_DATA d, *p; | ||
| 920 | unsigned long l; | 944 | unsigned long l; |
| 921 | 945 | ||
| 922 | err_fns_check(); | 946 | err_fns_check(); |
| 923 | l=ERR_GET_LIB(e); | 947 | l = ERR_GET_LIB(e); |
| 924 | d.error=ERR_PACK(l,0,0); | 948 | d.error = ERR_PACK(l, 0, 0); |
| 925 | p=ERRFN(err_get_item)(&d); | 949 | p = ERRFN(err_get_item)(&d); |
| 926 | return((p == NULL)?NULL:p->string); | 950 | return ((p == NULL) ? NULL : p->string); |
| 927 | } | 951 | } |
| 928 | 952 | ||
| 929 | const char *ERR_func_error_string(unsigned long e) | 953 | const char * |
| 930 | { | 954 | ERR_func_error_string(unsigned long e) |
| 931 | ERR_STRING_DATA d,*p; | 955 | { |
| 932 | unsigned long l,f; | 956 | ERR_STRING_DATA d, *p; |
| 957 | unsigned long l, f; | ||
| 933 | 958 | ||
| 934 | err_fns_check(); | 959 | err_fns_check(); |
| 935 | l=ERR_GET_LIB(e); | 960 | l = ERR_GET_LIB(e); |
| 936 | f=ERR_GET_FUNC(e); | 961 | f = ERR_GET_FUNC(e); |
| 937 | d.error=ERR_PACK(l,f,0); | 962 | d.error = ERR_PACK(l, f, 0); |
| 938 | p=ERRFN(err_get_item)(&d); | 963 | p = ERRFN(err_get_item)(&d); |
| 939 | return((p == NULL)?NULL:p->string); | 964 | return ((p == NULL) ? NULL : p->string); |
| 940 | } | 965 | } |
| 941 | 966 | ||
| 942 | const char *ERR_reason_error_string(unsigned long e) | 967 | const char * |
| 943 | { | 968 | ERR_reason_error_string(unsigned long e) |
| 944 | ERR_STRING_DATA d,*p=NULL; | 969 | { |
| 945 | unsigned long l,r; | 970 | ERR_STRING_DATA d, *p = NULL; |
| 971 | unsigned long l, r; | ||
| 946 | 972 | ||
| 947 | err_fns_check(); | 973 | err_fns_check(); |
| 948 | l=ERR_GET_LIB(e); | 974 | l = ERR_GET_LIB(e); |
| 949 | r=ERR_GET_REASON(e); | 975 | r = ERR_GET_REASON(e); |
| 950 | d.error=ERR_PACK(l,0,r); | 976 | d.error = ERR_PACK(l, 0, r); |
| 951 | p=ERRFN(err_get_item)(&d); | 977 | p = ERRFN(err_get_item)(&d); |
| 952 | if (!p) | 978 | if (!p) { |
| 953 | { | 979 | d.error = ERR_PACK(0, 0, r); |
| 954 | d.error=ERR_PACK(0,0,r); | 980 | p = ERRFN(err_get_item)(&d); |
| 955 | p=ERRFN(err_get_item)(&d); | ||
| 956 | } | ||
| 957 | return((p == NULL)?NULL:p->string); | ||
| 958 | } | 981 | } |
| 982 | return ((p == NULL) ? NULL : p->string); | ||
| 983 | } | ||
| 959 | 984 | ||
| 960 | void ERR_remove_thread_state(const CRYPTO_THREADID *id) | 985 | void |
| 961 | { | 986 | ERR_remove_thread_state(const CRYPTO_THREADID *id) |
| 987 | { | ||
| 962 | ERR_STATE tmp; | 988 | ERR_STATE tmp; |
| 963 | 989 | ||
| 964 | if (id) | 990 | if (id) |
| @@ -969,147 +995,151 @@ void ERR_remove_thread_state(const CRYPTO_THREADID *id) | |||
| 969 | /* thread_del_item automatically destroys the LHASH if the number of | 995 | /* thread_del_item automatically destroys the LHASH if the number of |
| 970 | * items reaches zero. */ | 996 | * items reaches zero. */ |
| 971 | ERRFN(thread_del_item)(&tmp); | 997 | ERRFN(thread_del_item)(&tmp); |
| 972 | } | 998 | } |
| 973 | 999 | ||
| 974 | #ifndef OPENSSL_NO_DEPRECATED | 1000 | #ifndef OPENSSL_NO_DEPRECATED |
| 975 | void ERR_remove_state(unsigned long pid) | 1001 | void |
| 976 | { | 1002 | ERR_remove_state(unsigned long pid) |
| 1003 | { | ||
| 977 | ERR_remove_thread_state(NULL); | 1004 | ERR_remove_thread_state(NULL); |
| 978 | } | 1005 | } |
| 979 | #endif | 1006 | #endif |
| 980 | 1007 | ||
| 981 | ERR_STATE *ERR_get_state(void) | 1008 | ERR_STATE * |
| 982 | { | 1009 | ERR_get_state(void) |
| 1010 | { | ||
| 983 | static ERR_STATE fallback; | 1011 | static ERR_STATE fallback; |
| 984 | ERR_STATE *ret,tmp,*tmpp=NULL; | 1012 | ERR_STATE *ret, tmp, *tmpp = NULL; |
| 985 | int i; | 1013 | int i; |
| 986 | CRYPTO_THREADID tid; | 1014 | CRYPTO_THREADID tid; |
| 987 | 1015 | ||
| 988 | err_fns_check(); | 1016 | err_fns_check(); |
| 989 | CRYPTO_THREADID_current(&tid); | 1017 | CRYPTO_THREADID_current(&tid); |
| 990 | CRYPTO_THREADID_cpy(&tmp.tid, &tid); | 1018 | CRYPTO_THREADID_cpy(&tmp.tid, &tid); |
| 991 | ret=ERRFN(thread_get_item)(&tmp); | 1019 | ret = ERRFN(thread_get_item)(&tmp); |
| 992 | 1020 | ||
| 993 | /* ret == the error state, if NULL, make a new one */ | 1021 | /* ret == the error state, if NULL, make a new one */ |
| 994 | if (ret == NULL) | 1022 | if (ret == NULL) { |
| 995 | { | 1023 | ret = (ERR_STATE *)malloc(sizeof(ERR_STATE)); |
| 996 | ret=(ERR_STATE *)malloc(sizeof(ERR_STATE)); | 1024 | if (ret == NULL) |
| 997 | if (ret == NULL) return(&fallback); | 1025 | return (&fallback); |
| 998 | CRYPTO_THREADID_cpy(&ret->tid, &tid); | 1026 | CRYPTO_THREADID_cpy(&ret->tid, &tid); |
| 999 | ret->top=0; | 1027 | ret->top = 0; |
| 1000 | ret->bottom=0; | 1028 | ret->bottom = 0; |
| 1001 | for (i=0; i<ERR_NUM_ERRORS; i++) | 1029 | for (i = 0; i < ERR_NUM_ERRORS; i++) { |
| 1002 | { | 1030 | ret->err_data[i] = NULL; |
| 1003 | ret->err_data[i]=NULL; | 1031 | ret->err_data_flags[i] = 0; |
| 1004 | ret->err_data_flags[i]=0; | 1032 | } |
| 1005 | } | ||
| 1006 | tmpp = ERRFN(thread_set_item)(ret); | 1033 | tmpp = ERRFN(thread_set_item)(ret); |
| 1007 | /* To check if insertion failed, do a get. */ | 1034 | /* To check if insertion failed, do a get. */ |
| 1008 | if (ERRFN(thread_get_item)(ret) != ret) | 1035 | if (ERRFN(thread_get_item)(ret) != ret) { |
| 1009 | { | ||
| 1010 | ERR_STATE_free(ret); /* could not insert it */ | 1036 | ERR_STATE_free(ret); /* could not insert it */ |
| 1011 | return(&fallback); | 1037 | return (&fallback); |
| 1012 | } | 1038 | } |
| 1013 | /* If a race occured in this function and we came second, tmpp | 1039 | /* If a race occured in this function and we came second, tmpp |
| 1014 | * is the first one that we just replaced. */ | 1040 | * is the first one that we just replaced. */ |
| 1015 | if (tmpp) | 1041 | if (tmpp) |
| 1016 | ERR_STATE_free(tmpp); | 1042 | ERR_STATE_free(tmpp); |
| 1017 | } | ||
| 1018 | return ret; | ||
| 1019 | } | 1043 | } |
| 1044 | return ret; | ||
| 1045 | } | ||
| 1020 | 1046 | ||
| 1021 | int ERR_get_next_error_library(void) | 1047 | int |
| 1022 | { | 1048 | ERR_get_next_error_library(void) |
| 1049 | { | ||
| 1023 | err_fns_check(); | 1050 | err_fns_check(); |
| 1024 | return ERRFN(get_next_lib)(); | 1051 | return ERRFN(get_next_lib)(); |
| 1025 | } | 1052 | } |
| 1026 | 1053 | ||
| 1027 | void ERR_set_error_data(char *data, int flags) | 1054 | void |
| 1028 | { | 1055 | ERR_set_error_data(char *data, int flags) |
| 1056 | { | ||
| 1029 | ERR_STATE *es; | 1057 | ERR_STATE *es; |
| 1030 | int i; | 1058 | int i; |
| 1031 | 1059 | ||
| 1032 | es=ERR_get_state(); | 1060 | es = ERR_get_state(); |
| 1033 | 1061 | ||
| 1034 | i=es->top; | 1062 | i = es->top; |
| 1035 | if (i == 0) | 1063 | if (i == 0) |
| 1036 | i=ERR_NUM_ERRORS-1; | 1064 | i = ERR_NUM_ERRORS - 1; |
| 1037 | 1065 | ||
| 1038 | err_clear_data(es,i); | 1066 | err_clear_data(es, i); |
| 1039 | es->err_data[i]=data; | 1067 | es->err_data[i] = data; |
| 1040 | es->err_data_flags[i]=flags; | 1068 | es->err_data_flags[i] = flags; |
| 1041 | } | 1069 | } |
| 1042 | 1070 | ||
| 1043 | void ERR_add_error_data(int num, ...) | 1071 | void |
| 1044 | { | 1072 | ERR_add_error_data(int num, ...) |
| 1073 | { | ||
| 1045 | va_list args; | 1074 | va_list args; |
| 1046 | va_start(args, num); | 1075 | va_start(args, num); |
| 1047 | ERR_add_error_vdata(num, args); | 1076 | ERR_add_error_vdata(num, args); |
| 1048 | va_end(args); | 1077 | va_end(args); |
| 1049 | } | 1078 | } |
| 1050 | 1079 | ||
| 1051 | void ERR_add_error_vdata(int num, va_list args) | 1080 | void |
| 1052 | { | 1081 | ERR_add_error_vdata(int num, va_list args) |
| 1053 | int i,n,s; | 1082 | { |
| 1054 | char *str,*p,*a; | 1083 | int i, n, s; |
| 1084 | char *str, *p, *a; | ||
| 1055 | 1085 | ||
| 1056 | s=80; | 1086 | s = 80; |
| 1057 | str=malloc(s+1); | 1087 | str = malloc(s + 1); |
| 1058 | if (str == NULL) return; | 1088 | if (str == NULL) |
| 1059 | str[0]='\0'; | 1089 | return; |
| 1090 | str[0] = '\0'; | ||
| 1060 | 1091 | ||
| 1061 | n=0; | 1092 | n = 0; |
| 1062 | for (i=0; i<num; i++) | 1093 | for (i = 0; i < num; i++) { |
| 1063 | { | 1094 | a = va_arg(args, char*); |
| 1064 | a=va_arg(args, char*); | ||
| 1065 | /* ignore NULLs, thanks to Bob Beck <beck@obtuse.com> */ | 1095 | /* ignore NULLs, thanks to Bob Beck <beck@obtuse.com> */ |
| 1066 | if (a != NULL) | 1096 | if (a != NULL) { |
| 1067 | { | 1097 | n += strlen(a); |
| 1068 | n+=strlen(a); | 1098 | if (n > s) { |
| 1069 | if (n > s) | 1099 | s = n + 20; |
| 1070 | { | 1100 | p = realloc(str, s + 1); |
| 1071 | s=n+20; | 1101 | if (p == NULL) { |
| 1072 | p=realloc(str,s+1); | ||
| 1073 | if (p == NULL) | ||
| 1074 | { | ||
| 1075 | free(str); | 1102 | free(str); |
| 1076 | return; | 1103 | return; |
| 1077 | } | 1104 | } else |
| 1078 | else | 1105 | str = p; |
| 1079 | str=p; | ||
| 1080 | } | ||
| 1081 | strlcat(str,a,(size_t)s+1); | ||
| 1082 | } | 1106 | } |
| 1107 | strlcat(str, a, (size_t)s + 1); | ||
| 1083 | } | 1108 | } |
| 1084 | ERR_set_error_data(str,ERR_TXT_MALLOCED|ERR_TXT_STRING); | ||
| 1085 | } | 1109 | } |
| 1110 | ERR_set_error_data(str, ERR_TXT_MALLOCED|ERR_TXT_STRING); | ||
| 1111 | } | ||
| 1086 | 1112 | ||
| 1087 | int ERR_set_mark(void) | 1113 | int |
| 1088 | { | 1114 | ERR_set_mark(void) |
| 1115 | { | ||
| 1089 | ERR_STATE *es; | 1116 | ERR_STATE *es; |
| 1090 | 1117 | ||
| 1091 | es=ERR_get_state(); | 1118 | es = ERR_get_state(); |
| 1092 | 1119 | ||
| 1093 | if (es->bottom == es->top) return 0; | 1120 | if (es->bottom == es->top) |
| 1094 | es->err_flags[es->top]|=ERR_FLAG_MARK; | 1121 | return 0; |
| 1122 | es->err_flags[es->top] |= ERR_FLAG_MARK; | ||
| 1095 | return 1; | 1123 | return 1; |
| 1096 | } | 1124 | } |
| 1097 | 1125 | ||
| 1098 | int ERR_pop_to_mark(void) | 1126 | int |
| 1099 | { | 1127 | ERR_pop_to_mark(void) |
| 1128 | { | ||
| 1100 | ERR_STATE *es; | 1129 | ERR_STATE *es; |
| 1101 | 1130 | ||
| 1102 | es=ERR_get_state(); | 1131 | es = ERR_get_state(); |
| 1103 | 1132 | ||
| 1104 | while(es->bottom != es->top | 1133 | while (es->bottom != es->top && |
| 1105 | && (es->err_flags[es->top] & ERR_FLAG_MARK) == 0) | 1134 | (es->err_flags[es->top] & ERR_FLAG_MARK) == 0) { |
| 1106 | { | 1135 | err_clear(es, es->top); |
| 1107 | err_clear(es,es->top); | 1136 | es->top -= 1; |
| 1108 | es->top-=1; | 1137 | if (es->top == -1) |
| 1109 | if (es->top == -1) es->top=ERR_NUM_ERRORS-1; | 1138 | es->top = ERR_NUM_ERRORS - 1; |
| 1110 | } | 1139 | } |
| 1111 | 1140 | ||
| 1112 | if (es->bottom == es->top) return 0; | 1141 | if (es->bottom == es->top) |
| 1142 | return 0; | ||
| 1113 | es->err_flags[es->top]&=~ERR_FLAG_MARK; | 1143 | es->err_flags[es->top]&=~ERR_FLAG_MARK; |
| 1114 | return 1; | 1144 | return 1; |
| 1115 | } | 1145 | } |
diff --git a/src/lib/libssl/src/crypto/err/err.h b/src/lib/libssl/src/crypto/err/err.h index 974cc9cc6f..87dfef2456 100644 --- a/src/lib/libssl/src/crypto/err/err.h +++ b/src/lib/libssl/src/crypto/err/err.h | |||
| @@ -5,21 +5,21 @@ | |||
| 5 | * This package is an SSL implementation written | 5 | * This package is an SSL implementation written |
| 6 | * by Eric Young (eay@cryptsoft.com). | 6 | * by Eric Young (eay@cryptsoft.com). |
| 7 | * The implementation was written so as to conform with Netscapes SSL. | 7 | * The implementation was written so as to conform with Netscapes SSL. |
| 8 | * | 8 | * |
| 9 | * This library is free for commercial and non-commercial use as long as | 9 | * This library is free for commercial and non-commercial use as long as |
| 10 | * the following conditions are aheared to. The following conditions | 10 | * the following conditions are aheared to. The following conditions |
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | 11 | * apply to all code found in this distribution, be it the RC4, RSA, |
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation |
| 13 | * included with this distribution is covered by the same copyright terms | 13 | * included with this distribution is covered by the same copyright terms |
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
| 15 | * | 15 | * |
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | 16 | * Copyright remains Eric Young's, and as such any Copyright notices in |
| 17 | * the code are not to be removed. | 17 | * the code are not to be removed. |
| 18 | * If this package is used in a product, Eric Young should be given attribution | 18 | * If this package is used in a product, Eric Young should be given attribution |
| 19 | * as the author of the parts of the library used. | 19 | * as the author of the parts of the library used. |
| 20 | * This can be in the form of a textual message at program startup or | 20 | * This can be in the form of a textual message at program startup or |
| 21 | * in documentation (online or textual) provided with the package. | 21 | * in documentation (online or textual) provided with the package. |
| 22 | * | 22 | * |
| 23 | * Redistribution and use in source and binary forms, with or without | 23 | * Redistribution and use in source and binary forms, with or without |
| 24 | * modification, are permitted provided that the following conditions | 24 | * modification, are permitted provided that the following conditions |
| 25 | * are met: | 25 | * are met: |
| @@ -34,10 +34,10 @@ | |||
| 34 | * Eric Young (eay@cryptsoft.com)" | 34 | * Eric Young (eay@cryptsoft.com)" |
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | 35 | * The word 'cryptographic' can be left out if the rouines from the library |
| 36 | * being used are not cryptographic related :-). | 36 | * being used are not cryptographic related :-). |
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | 37 | * 4. If you include any Windows specific code (or a derivative thereof) from |
| 38 | * the apps directory (application code) you must include an acknowledgement: | 38 | * the apps directory (application code) you must include an acknowledgement: |
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
| 40 | * | 40 | * |
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| @@ -49,7 +49,7 @@ | |||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. |
| 52 | * | 52 | * |
| 53 | * The licence and distribution terms for any publically available version or | 53 | * The licence and distribution terms for any publically available version or |
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
| 55 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
| @@ -63,7 +63,7 @@ | |||
| 63 | * are met: | 63 | * are met: |
| 64 | * | 64 | * |
| 65 | * 1. Redistributions of source code must retain the above copyright | 65 | * 1. Redistributions of source code must retain the above copyright |
| 66 | * notice, this list of conditions and the following disclaimer. | 66 | * notice, this list of conditions and the following disclaimer. |
| 67 | * | 67 | * |
| 68 | * 2. Redistributions in binary form must reproduce the above copyright | 68 | * 2. Redistributions in binary form must reproduce the above copyright |
| 69 | * notice, this list of conditions and the following disclaimer in | 69 | * notice, this list of conditions and the following disclaimer in |
| @@ -145,8 +145,7 @@ extern "C" { | |||
| 145 | #define ERR_FLAG_MARK 0x01 | 145 | #define ERR_FLAG_MARK 0x01 |
| 146 | 146 | ||
| 147 | #define ERR_NUM_ERRORS 16 | 147 | #define ERR_NUM_ERRORS 16 |
| 148 | typedef struct err_state_st | 148 | typedef struct err_state_st { |
| 149 | { | ||
| 150 | CRYPTO_THREADID tid; | 149 | CRYPTO_THREADID tid; |
| 151 | int err_flags[ERR_NUM_ERRORS]; | 150 | int err_flags[ERR_NUM_ERRORS]; |
| 152 | unsigned long err_buffer[ERR_NUM_ERRORS]; | 151 | unsigned long err_buffer[ERR_NUM_ERRORS]; |
| @@ -154,8 +153,8 @@ typedef struct err_state_st | |||
| 154 | int err_data_flags[ERR_NUM_ERRORS]; | 153 | int err_data_flags[ERR_NUM_ERRORS]; |
| 155 | const char *err_file[ERR_NUM_ERRORS]; | 154 | const char *err_file[ERR_NUM_ERRORS]; |
| 156 | int err_line[ERR_NUM_ERRORS]; | 155 | int err_line[ERR_NUM_ERRORS]; |
| 157 | int top,bottom; | 156 | int top, bottom; |
| 158 | } ERR_STATE; | 157 | } ERR_STATE; |
| 159 | 158 | ||
| 160 | /* library */ | 159 | /* library */ |
| 161 | #define ERR_LIB_NONE 1 | 160 | #define ERR_LIB_NONE 1 |
| @@ -310,35 +309,34 @@ typedef struct err_state_st | |||
| 310 | * are reserved for the individual libraries */ | 309 | * are reserved for the individual libraries */ |
| 311 | 310 | ||
| 312 | 311 | ||
| 313 | typedef struct ERR_string_data_st | 312 | typedef struct ERR_string_data_st { |
| 314 | { | ||
| 315 | unsigned long error; | 313 | unsigned long error; |
| 316 | const char *string; | 314 | const char *string; |
| 317 | } ERR_STRING_DATA; | 315 | } ERR_STRING_DATA; |
| 318 | 316 | ||
| 319 | void ERR_put_error(int lib, int func,int reason,const char *file,int line); | 317 | void ERR_put_error(int lib, int func, int reason, const char *file, int line); |
| 320 | void ERR_set_error_data(char *data,int flags); | 318 | void ERR_set_error_data(char *data, int flags); |
| 321 | 319 | ||
| 322 | unsigned long ERR_get_error(void); | 320 | unsigned long ERR_get_error(void); |
| 323 | unsigned long ERR_get_error_line(const char **file,int *line); | 321 | unsigned long ERR_get_error_line(const char **file, int *line); |
| 324 | unsigned long ERR_get_error_line_data(const char **file,int *line, | 322 | unsigned long ERR_get_error_line_data(const char **file, int *line, |
| 325 | const char **data, int *flags); | 323 | const char **data, int *flags); |
| 326 | unsigned long ERR_peek_error(void); | 324 | unsigned long ERR_peek_error(void); |
| 327 | unsigned long ERR_peek_error_line(const char **file,int *line); | 325 | unsigned long ERR_peek_error_line(const char **file, int *line); |
| 328 | unsigned long ERR_peek_error_line_data(const char **file,int *line, | 326 | unsigned long ERR_peek_error_line_data(const char **file, int *line, |
| 329 | const char **data,int *flags); | 327 | const char **data, int *flags); |
| 330 | unsigned long ERR_peek_last_error(void); | 328 | unsigned long ERR_peek_last_error(void); |
| 331 | unsigned long ERR_peek_last_error_line(const char **file,int *line); | 329 | unsigned long ERR_peek_last_error_line(const char **file, int *line); |
| 332 | unsigned long ERR_peek_last_error_line_data(const char **file,int *line, | 330 | unsigned long ERR_peek_last_error_line_data(const char **file, int *line, |
| 333 | const char **data,int *flags); | 331 | const char **data, int *flags); |
| 334 | void ERR_clear_error(void ); | 332 | void ERR_clear_error(void ); |
| 335 | char *ERR_error_string(unsigned long e,char *buf); | 333 | char *ERR_error_string(unsigned long e, char *buf); |
| 336 | void ERR_error_string_n(unsigned long e, char *buf, size_t len); | 334 | void ERR_error_string_n(unsigned long e, char *buf, size_t len); |
| 337 | const char *ERR_lib_error_string(unsigned long e); | 335 | const char *ERR_lib_error_string(unsigned long e); |
| 338 | const char *ERR_func_error_string(unsigned long e); | 336 | const char *ERR_func_error_string(unsigned long e); |
| 339 | const char *ERR_reason_error_string(unsigned long e); | 337 | const char *ERR_reason_error_string(unsigned long e); |
| 340 | void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u), | 338 | void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u), |
| 341 | void *u); | 339 | void *u); |
| 342 | #ifndef OPENSSL_NO_FP_API | 340 | #ifndef OPENSSL_NO_FP_API |
| 343 | void ERR_print_errors_fp(FILE *fp); | 341 | void ERR_print_errors_fp(FILE *fp); |
| 344 | #endif | 342 | #endif |
| @@ -347,8 +345,8 @@ void ERR_print_errors(BIO *bp); | |||
| 347 | #endif | 345 | #endif |
| 348 | void ERR_add_error_data(int num, ...); | 346 | void ERR_add_error_data(int num, ...); |
| 349 | void ERR_add_error_vdata(int num, va_list args); | 347 | void ERR_add_error_vdata(int num, va_list args); |
| 350 | void ERR_load_strings(int lib,ERR_STRING_DATA str[]); | 348 | void ERR_load_strings(int lib, ERR_STRING_DATA str[]); |
| 351 | void ERR_unload_strings(int lib,ERR_STRING_DATA str[]); | 349 | void ERR_unload_strings(int lib, ERR_STRING_DATA str[]); |
| 352 | void ERR_load_ERR_strings(void); | 350 | void ERR_load_ERR_strings(void); |
| 353 | void ERR_load_crypto_strings(void); | 351 | void ERR_load_crypto_strings(void); |
| 354 | void ERR_free_strings(void); | 352 | void ERR_free_strings(void); |
diff --git a/src/lib/libssl/src/crypto/err/err_all.c b/src/lib/libssl/src/crypto/err/err_all.c index 1c4eccd251..1350c61296 100644 --- a/src/lib/libssl/src/crypto/err/err_all.c +++ b/src/lib/libssl/src/crypto/err/err_all.c | |||
| @@ -5,21 +5,21 @@ | |||
| 5 | * This package is an SSL implementation written | 5 | * This package is an SSL implementation written |
| 6 | * by Eric Young (eay@cryptsoft.com). | 6 | * by Eric Young (eay@cryptsoft.com). |
| 7 | * The implementation was written so as to conform with Netscapes SSL. | 7 | * The implementation was written so as to conform with Netscapes SSL. |
| 8 | * | 8 | * |
| 9 | * This library is free for commercial and non-commercial use as long as | 9 | * This library is free for commercial and non-commercial use as long as |
| 10 | * the following conditions are aheared to. The following conditions | 10 | * the following conditions are aheared to. The following conditions |
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | 11 | * apply to all code found in this distribution, be it the RC4, RSA, |
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation |
| 13 | * included with this distribution is covered by the same copyright terms | 13 | * included with this distribution is covered by the same copyright terms |
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
| 15 | * | 15 | * |
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | 16 | * Copyright remains Eric Young's, and as such any Copyright notices in |
| 17 | * the code are not to be removed. | 17 | * the code are not to be removed. |
| 18 | * If this package is used in a product, Eric Young should be given attribution | 18 | * If this package is used in a product, Eric Young should be given attribution |
| 19 | * as the author of the parts of the library used. | 19 | * as the author of the parts of the library used. |
| 20 | * This can be in the form of a textual message at program startup or | 20 | * This can be in the form of a textual message at program startup or |
| 21 | * in documentation (online or textual) provided with the package. | 21 | * in documentation (online or textual) provided with the package. |
| 22 | * | 22 | * |
| 23 | * Redistribution and use in source and binary forms, with or without | 23 | * Redistribution and use in source and binary forms, with or without |
| 24 | * modification, are permitted provided that the following conditions | 24 | * modification, are permitted provided that the following conditions |
| 25 | * are met: | 25 | * are met: |
| @@ -34,10 +34,10 @@ | |||
| 34 | * Eric Young (eay@cryptsoft.com)" | 34 | * Eric Young (eay@cryptsoft.com)" |
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | 35 | * The word 'cryptographic' can be left out if the rouines from the library |
| 36 | * being used are not cryptographic related :-). | 36 | * being used are not cryptographic related :-). |
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | 37 | * 4. If you include any Windows specific code (or a derivative thereof) from |
| 38 | * the apps directory (application code) you must include an acknowledgement: | 38 | * the apps directory (application code) you must include an acknowledgement: |
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
| 40 | * | 40 | * |
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| @@ -49,7 +49,7 @@ | |||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. |
| 52 | * | 52 | * |
| 53 | * The licence and distribution terms for any publically available version or | 53 | * The licence and distribution terms for any publically available version or |
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
| 55 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
| @@ -105,8 +105,9 @@ | |||
| 105 | #include <openssl/jpake.h> | 105 | #include <openssl/jpake.h> |
| 106 | #endif | 106 | #endif |
| 107 | 107 | ||
| 108 | void ERR_load_crypto_strings(void) | 108 | void |
| 109 | { | 109 | ERR_load_crypto_strings(void) |
| 110 | { | ||
| 110 | #ifndef OPENSSL_NO_ERR | 111 | #ifndef OPENSSL_NO_ERR |
| 111 | ERR_load_ERR_strings(); /* include error strings for SYSerr */ | 112 | ERR_load_ERR_strings(); /* include error strings for SYSerr */ |
| 112 | ERR_load_BN_strings(); | 113 | ERR_load_BN_strings(); |
| @@ -141,7 +142,7 @@ void ERR_load_crypto_strings(void) | |||
| 141 | #endif | 142 | #endif |
| 142 | /* skip ERR_load_SSL_strings() because it is not in this library */ | 143 | /* skip ERR_load_SSL_strings() because it is not in this library */ |
| 143 | ERR_load_BIO_strings(); | 144 | ERR_load_BIO_strings(); |
| 144 | ERR_load_PKCS7_strings(); | 145 | ERR_load_PKCS7_strings(); |
| 145 | ERR_load_X509V3_strings(); | 146 | ERR_load_X509V3_strings(); |
| 146 | ERR_load_PKCS12_strings(); | 147 | ERR_load_PKCS12_strings(); |
| 147 | ERR_load_RAND_strings(); | 148 | ERR_load_RAND_strings(); |
| @@ -159,4 +160,4 @@ void ERR_load_crypto_strings(void) | |||
| 159 | ERR_load_JPAKE_strings(); | 160 | ERR_load_JPAKE_strings(); |
| 160 | #endif | 161 | #endif |
| 161 | #endif | 162 | #endif |
| 162 | } | 163 | } |
diff --git a/src/lib/libssl/src/crypto/err/err_prn.c b/src/lib/libssl/src/crypto/err/err_prn.c index 7374c0abe7..d6b488fee9 100644 --- a/src/lib/libssl/src/crypto/err/err_prn.c +++ b/src/lib/libssl/src/crypto/err/err_prn.c | |||
| @@ -5,21 +5,21 @@ | |||
| 5 | * This package is an SSL implementation written | 5 | * This package is an SSL implementation written |
| 6 | * by Eric Young (eay@cryptsoft.com). | 6 | * by Eric Young (eay@cryptsoft.com). |
| 7 | * The implementation was written so as to conform with Netscapes SSL. | 7 | * The implementation was written so as to conform with Netscapes SSL. |
| 8 | * | 8 | * |
| 9 | * This library is free for commercial and non-commercial use as long as | 9 | * This library is free for commercial and non-commercial use as long as |
| 10 | * the following conditions are aheared to. The following conditions | 10 | * the following conditions are aheared to. The following conditions |
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | 11 | * apply to all code found in this distribution, be it the RC4, RSA, |
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation |
| 13 | * included with this distribution is covered by the same copyright terms | 13 | * included with this distribution is covered by the same copyright terms |
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
| 15 | * | 15 | * |
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | 16 | * Copyright remains Eric Young's, and as such any Copyright notices in |
| 17 | * the code are not to be removed. | 17 | * the code are not to be removed. |
| 18 | * If this package is used in a product, Eric Young should be given attribution | 18 | * If this package is used in a product, Eric Young should be given attribution |
| 19 | * as the author of the parts of the library used. | 19 | * as the author of the parts of the library used. |
| 20 | * This can be in the form of a textual message at program startup or | 20 | * This can be in the form of a textual message at program startup or |
| 21 | * in documentation (online or textual) provided with the package. | 21 | * in documentation (online or textual) provided with the package. |
| 22 | * | 22 | * |
| 23 | * Redistribution and use in source and binary forms, with or without | 23 | * Redistribution and use in source and binary forms, with or without |
| 24 | * modification, are permitted provided that the following conditions | 24 | * modification, are permitted provided that the following conditions |
| 25 | * are met: | 25 | * are met: |
| @@ -34,10 +34,10 @@ | |||
| 34 | * Eric Young (eay@cryptsoft.com)" | 34 | * Eric Young (eay@cryptsoft.com)" |
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | 35 | * The word 'cryptographic' can be left out if the rouines from the library |
| 36 | * being used are not cryptographic related :-). | 36 | * being used are not cryptographic related :-). |
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | 37 | * 4. If you include any Windows specific code (or a derivative thereof) from |
| 38 | * the apps directory (application code) you must include an acknowledgement: | 38 | * the apps directory (application code) you must include an acknowledgement: |
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
| 40 | * | 40 | * |
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| @@ -49,7 +49,7 @@ | |||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. |
| 52 | * | 52 | * |
| 53 | * The licence and distribution terms for any publically available version or | 53 | * The licence and distribution terms for any publically available version or |
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
| 55 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
| @@ -63,52 +63,56 @@ | |||
| 63 | #include <openssl/buffer.h> | 63 | #include <openssl/buffer.h> |
| 64 | #include <openssl/err.h> | 64 | #include <openssl/err.h> |
| 65 | 65 | ||
| 66 | void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u), | 66 | void |
| 67 | void *u) | 67 | ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u), void *u) |
| 68 | { | 68 | { |
| 69 | unsigned long l; | 69 | unsigned long l; |
| 70 | char buf[256]; | 70 | char buf[256]; |
| 71 | char buf2[4096]; | 71 | char buf2[4096]; |
| 72 | const char *file,*data; | 72 | const char *file, *data; |
| 73 | int line,flags; | 73 | int line, flags; |
| 74 | unsigned long es; | 74 | unsigned long es; |
| 75 | CRYPTO_THREADID cur; | 75 | CRYPTO_THREADID cur; |
| 76 | 76 | ||
| 77 | CRYPTO_THREADID_current(&cur); | 77 | CRYPTO_THREADID_current(&cur); |
| 78 | es=CRYPTO_THREADID_hash(&cur); | 78 | es = CRYPTO_THREADID_hash(&cur); |
| 79 | while ((l=ERR_get_error_line_data(&file,&line,&data,&flags)) != 0) | 79 | while ((l = ERR_get_error_line_data(&file, &line, &data, |
| 80 | { | 80 | &flags)) != 0) { |
| 81 | ERR_error_string_n(l, buf, sizeof buf); | 81 | ERR_error_string_n(l, buf, sizeof buf); |
| 82 | (void) snprintf(buf2, sizeof(buf2), "%lu:%s:%s:%d:%s\n", es, buf, | 82 | (void) snprintf(buf2, sizeof(buf2), "%lu:%s:%s:%d:%s\n", es, |
| 83 | file, line, (flags & ERR_TXT_STRING) ? data : ""); | 83 | buf, file, line, (flags & ERR_TXT_STRING) ? data : ""); |
| 84 | if (cb(buf2, strlen(buf2), u) <= 0) | 84 | if (cb(buf2, strlen(buf2), u) <= 0) |
| 85 | break; /* abort outputting the error report */ | 85 | break; /* abort outputting the error report */ |
| 86 | } | ||
| 87 | } | 86 | } |
| 87 | } | ||
| 88 | 88 | ||
| 89 | #ifndef OPENSSL_NO_FP_API | 89 | #ifndef OPENSSL_NO_FP_API |
| 90 | static int print_fp(const char *str, size_t len, void *fp) | 90 | static int |
| 91 | { | 91 | print_fp(const char *str, size_t len, void *fp) |
| 92 | { | ||
| 92 | BIO bio; | 93 | BIO bio; |
| 93 | 94 | ||
| 94 | BIO_set(&bio,BIO_s_file()); | 95 | BIO_set(&bio, BIO_s_file()); |
| 95 | BIO_set_fp(&bio,fp,BIO_NOCLOSE); | 96 | BIO_set_fp(&bio, fp, BIO_NOCLOSE); |
| 96 | 97 | ||
| 97 | return BIO_printf(&bio, "%s", str); | 98 | return BIO_printf(&bio, "%s", str); |
| 98 | } | 99 | } |
| 99 | void ERR_print_errors_fp(FILE *fp) | 100 | |
| 100 | { | 101 | void |
| 102 | ERR_print_errors_fp(FILE *fp) | ||
| 103 | { | ||
| 101 | ERR_print_errors_cb(print_fp, fp); | 104 | ERR_print_errors_cb(print_fp, fp); |
| 102 | } | 105 | } |
| 103 | #endif | 106 | #endif |
| 104 | 107 | ||
| 105 | static int print_bio(const char *str, size_t len, void *bp) | 108 | static int |
| 106 | { | 109 | print_bio(const char *str, size_t len, void *bp) |
| 110 | { | ||
| 107 | return BIO_write((BIO *)bp, str, len); | 111 | return BIO_write((BIO *)bp, str, len); |
| 108 | } | 112 | } |
| 109 | void ERR_print_errors(BIO *bp) | ||
| 110 | { | ||
| 111 | ERR_print_errors_cb(print_bio, bp); | ||
| 112 | } | ||
| 113 | 113 | ||
| 114 | 114 | void | |
| 115 | ERR_print_errors(BIO *bp) | ||
| 116 | { | ||
| 117 | ERR_print_errors_cb(print_bio, bp); | ||
| 118 | } | ||
