diff options
| author | beck <> | 2002-05-15 02:29:21 +0000 |
|---|---|---|
| committer | beck <> | 2002-05-15 02:29:21 +0000 |
| commit | b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9 (patch) | |
| tree | fa27cf82a1250b64ed3bf5f4a18c7354d470bbcc /src/lib/libcrypto/err | |
| parent | e471e1ea98d673597b182ea85f29e30c97cd08b5 (diff) | |
| download | openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.gz openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.bz2 openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.zip | |
OpenSSL 0.9.7 stable 2002 05 08 merge
Diffstat (limited to 'src/lib/libcrypto/err')
| -rw-r--r-- | src/lib/libcrypto/err/Makefile.ssl | 57 | ||||
| -rw-r--r-- | src/lib/libcrypto/err/err.c | 615 | ||||
| -rw-r--r-- | src/lib/libcrypto/err/err.h | 183 | ||||
| -rw-r--r-- | src/lib/libcrypto/err/err_all.c | 49 | ||||
| -rw-r--r-- | src/lib/libcrypto/err/err_prn.c | 46 | ||||
| -rw-r--r-- | src/lib/libcrypto/err/openssl.ec | 31 |
6 files changed, 618 insertions, 363 deletions
diff --git a/src/lib/libcrypto/err/Makefile.ssl b/src/lib/libcrypto/err/Makefile.ssl index 58218d1cea..4e69b9fbab 100644 --- a/src/lib/libcrypto/err/Makefile.ssl +++ b/src/lib/libcrypto/err/Makefile.ssl | |||
| @@ -5,13 +5,14 @@ | |||
| 5 | DIR= err | 5 | DIR= err |
| 6 | TOP= ../.. | 6 | TOP= ../.. |
| 7 | CC= cc | 7 | CC= cc |
| 8 | INCLUDES= -I.. -I../../include | 8 | INCLUDES= -I.. -I$(TOP) -I../../include |
| 9 | CFLAG=-g | 9 | CFLAG=-g |
| 10 | INSTALL_PREFIX= | 10 | INSTALL_PREFIX= |
| 11 | OPENSSLDIR= /usr/local/ssl | 11 | OPENSSLDIR= /usr/local/ssl |
| 12 | INSTALLTOP=/usr/local/ssl | 12 | INSTALLTOP=/usr/local/ssl |
| 13 | MAKE= make -f Makefile.ssl | 13 | MAKE= make -f Makefile.ssl |
| 14 | MAKEDEPEND= $(TOP)/util/domd $(TOP) | 14 | MAKEDEPPROG= makedepend |
| 15 | MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) | ||
| 15 | MAKEFILE= Makefile.ssl | 16 | MAKEFILE= Makefile.ssl |
| 16 | AR= ar r | 17 | AR= ar r |
| 17 | 18 | ||
| @@ -39,8 +40,7 @@ all: lib | |||
| 39 | 40 | ||
| 40 | lib: $(LIBOBJ) | 41 | lib: $(LIBOBJ) |
| 41 | $(AR) $(LIB) $(LIBOBJ) | 42 | $(AR) $(LIB) $(LIBOBJ) |
| 42 | @echo You may get an error following this line. Please ignore. | 43 | $(RANLIB) $(LIB) || echo Never mind. |
| 43 | - $(RANLIB) $(LIB) | ||
| 44 | @touch lib | 44 | @touch lib |
| 45 | 45 | ||
| 46 | files: | 46 | files: |
| @@ -79,39 +79,34 @@ clean: | |||
| 79 | 79 | ||
| 80 | # DO NOT DELETE THIS LINE -- make depend depends on it. | 80 | # DO NOT DELETE THIS LINE -- make depend depends on it. |
| 81 | 81 | ||
| 82 | err.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | 82 | err.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/buffer.h |
| 83 | err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h | 83 | err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h |
| 84 | err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | 84 | err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h |
| 85 | err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | 85 | err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h |
| 86 | err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h | 86 | err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h |
| 87 | err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 87 | err.o: ../../include/openssl/symhacks.h ../cryptlib.h err.c |
| 88 | err.o: ../cryptlib.h | ||
| 89 | err_all.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 88 | err_all.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h |
| 90 | err_all.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | 89 | err_all.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h |
| 91 | err_all.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
| 92 | err_all.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h | 90 | err_all.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h |
| 93 | err_all.o: ../../include/openssl/des.h ../../include/openssl/dh.h | 91 | err_all.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h |
| 94 | err_all.o: ../../include/openssl/dsa.h ../../include/openssl/dso.h | 92 | err_all.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h |
| 95 | err_all.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h | 93 | err_all.o: ../../include/openssl/ec.h ../../include/openssl/engine.h |
| 96 | err_all.o: ../../include/openssl/engine.h ../../include/openssl/err.h | 94 | err_all.o: ../../include/openssl/err.h ../../include/openssl/evp.h |
| 97 | err_all.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | 95 | err_all.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h |
| 98 | err_all.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | 96 | err_all.o: ../../include/openssl/objects.h ../../include/openssl/ocsp.h |
| 99 | err_all.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | 97 | err_all.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h |
| 100 | err_all.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | 98 | err_all.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem2.h |
| 101 | err_all.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
| 102 | err_all.o: ../../include/openssl/opensslv.h ../../include/openssl/pem2.h | ||
| 103 | err_all.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h | 99 | err_all.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h |
| 104 | err_all.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h | 100 | err_all.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h |
| 105 | err_all.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
| 106 | err_all.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
| 107 | err_all.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | 101 | err_all.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h |
| 108 | err_all.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 102 | err_all.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
| 109 | err_all.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | 103 | err_all.o: ../../include/openssl/ui.h ../../include/openssl/x509.h |
| 110 | err_all.o: ../../include/openssl/x509v3.h | 104 | err_all.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h |
| 111 | err_prn.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | 105 | err_all.o: err_all.c |
| 112 | err_prn.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h | 106 | err_prn.o: ../../e_os.h ../../include/openssl/bio.h |
| 107 | err_prn.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 113 | err_prn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | 108 | err_prn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h |
| 114 | err_prn.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | 109 | err_prn.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h |
| 115 | err_prn.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h | 110 | err_prn.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h |
| 116 | err_prn.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 111 | err_prn.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
| 117 | err_prn.o: ../cryptlib.h | 112 | err_prn.o: ../cryptlib.h err_prn.c |
diff --git a/src/lib/libcrypto/err/err.c b/src/lib/libcrypto/err/err.c index 839f4ab81a..04773d65a6 100644 --- a/src/lib/libcrypto/err/err.c +++ b/src/lib/libcrypto/err/err.c | |||
| @@ -56,7 +56,7 @@ | |||
| 56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
| 57 | */ | 57 | */ |
| 58 | /* ==================================================================== | 58 | /* ==================================================================== |
| 59 | * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. | 59 | * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. |
| 60 | * | 60 | * |
| 61 | * Redistribution and use in source and binary forms, with or without | 61 | * Redistribution and use in source and binary forms, with or without |
| 62 | * modification, are permitted provided that the following conditions | 62 | * modification, are permitted provided that the following conditions |
| @@ -119,38 +119,28 @@ | |||
| 119 | #include <openssl/bio.h> | 119 | #include <openssl/bio.h> |
| 120 | #include <openssl/err.h> | 120 | #include <openssl/err.h> |
| 121 | 121 | ||
| 122 | static void err_load_strings(int lib, ERR_STRING_DATA *str); | ||
| 122 | 123 | ||
| 123 | static LHASH *error_hash=NULL; | ||
| 124 | static LHASH *thread_hash=NULL; | ||
| 125 | |||
| 126 | static unsigned long err_hash(ERR_STRING_DATA *a); | ||
| 127 | static int err_cmp(ERR_STRING_DATA *a, ERR_STRING_DATA *b); | ||
| 128 | static unsigned long pid_hash(ERR_STATE *pid); | ||
| 129 | static int pid_cmp(ERR_STATE *a,ERR_STATE *pid); | ||
| 130 | static unsigned long get_error_values(int inc,const char **file,int *line, | ||
| 131 | const char **data,int *flags); | ||
| 132 | static void ERR_STATE_free(ERR_STATE *s); | 124 | static void ERR_STATE_free(ERR_STATE *s); |
| 133 | #ifndef NO_ERR | 125 | #ifndef OPENSSL_NO_ERR |
| 134 | static ERR_STRING_DATA ERR_str_libraries[]= | 126 | static ERR_STRING_DATA ERR_str_libraries[]= |
| 135 | { | 127 | { |
| 136 | {ERR_PACK(ERR_LIB_NONE,0,0) ,"unknown library"}, | 128 | {ERR_PACK(ERR_LIB_NONE,0,0) ,"unknown library"}, |
| 137 | {ERR_PACK(ERR_LIB_SYS,0,0) ,"system library"}, | 129 | {ERR_PACK(ERR_LIB_SYS,0,0) ,"system library"}, |
| 138 | {ERR_PACK(ERR_LIB_BN,0,0) ,"bignum routines"}, | 130 | {ERR_PACK(ERR_LIB_BN,0,0) ,"bignum routines"}, |
| 139 | {ERR_PACK(ERR_LIB_RSA,0,0) ,"rsa routines"}, | 131 | {ERR_PACK(ERR_LIB_RSA,0,0) ,"rsa routines"}, |
| 140 | {ERR_PACK(ERR_LIB_DSA,0,0) ,"dsa routines"}, | ||
| 141 | {ERR_PACK(ERR_LIB_DH,0,0) ,"Diffie-Hellman routines"}, | 132 | {ERR_PACK(ERR_LIB_DH,0,0) ,"Diffie-Hellman routines"}, |
| 142 | {ERR_PACK(ERR_LIB_EVP,0,0) ,"digital envelope routines"}, | 133 | {ERR_PACK(ERR_LIB_EVP,0,0) ,"digital envelope routines"}, |
| 143 | {ERR_PACK(ERR_LIB_BUF,0,0) ,"memory buffer routines"}, | 134 | {ERR_PACK(ERR_LIB_BUF,0,0) ,"memory buffer routines"}, |
| 144 | {ERR_PACK(ERR_LIB_BIO,0,0) ,"BIO routines"}, | ||
| 145 | {ERR_PACK(ERR_LIB_OBJ,0,0) ,"object identifier routines"}, | 135 | {ERR_PACK(ERR_LIB_OBJ,0,0) ,"object identifier routines"}, |
| 146 | {ERR_PACK(ERR_LIB_PEM,0,0) ,"PEM routines"}, | 136 | {ERR_PACK(ERR_LIB_PEM,0,0) ,"PEM routines"}, |
| 147 | {ERR_PACK(ERR_LIB_ASN1,0,0) ,"asn1 encoding routines"}, | 137 | {ERR_PACK(ERR_LIB_DSA,0,0) ,"dsa routines"}, |
| 148 | {ERR_PACK(ERR_LIB_X509,0,0) ,"x509 certificate routines"}, | 138 | {ERR_PACK(ERR_LIB_X509,0,0) ,"x509 certificate routines"}, |
| 139 | {ERR_PACK(ERR_LIB_ASN1,0,0) ,"asn1 encoding routines"}, | ||
| 149 | {ERR_PACK(ERR_LIB_CONF,0,0) ,"configuration file routines"}, | 140 | {ERR_PACK(ERR_LIB_CONF,0,0) ,"configuration file routines"}, |
| 150 | {ERR_PACK(ERR_LIB_METH,0,0) ,"X509 lookup 'method' routines"}, | 141 | {ERR_PACK(ERR_LIB_CRYPTO,0,0) ,"common libcrypto routines"}, |
| 142 | {ERR_PACK(ERR_LIB_EC,0,0) ,"elliptic curve routines"}, | ||
| 151 | {ERR_PACK(ERR_LIB_SSL,0,0) ,"SSL routines"}, | 143 | {ERR_PACK(ERR_LIB_SSL,0,0) ,"SSL routines"}, |
| 152 | {ERR_PACK(ERR_LIB_RSAREF,0,0) ,"RSAref routines"}, | ||
| 153 | {ERR_PACK(ERR_LIB_PROXY,0,0) ,"Proxy routines"}, | ||
| 154 | {ERR_PACK(ERR_LIB_BIO,0,0) ,"BIO routines"}, | 144 | {ERR_PACK(ERR_LIB_BIO,0,0) ,"BIO routines"}, |
| 155 | {ERR_PACK(ERR_LIB_PKCS7,0,0) ,"PKCS7 routines"}, | 145 | {ERR_PACK(ERR_LIB_PKCS7,0,0) ,"PKCS7 routines"}, |
| 156 | {ERR_PACK(ERR_LIB_X509V3,0,0) ,"X509 V3 routines"}, | 146 | {ERR_PACK(ERR_LIB_X509V3,0,0) ,"X509 V3 routines"}, |
| @@ -158,6 +148,7 @@ static ERR_STRING_DATA ERR_str_libraries[]= | |||
| 158 | {ERR_PACK(ERR_LIB_RAND,0,0) ,"random number generator"}, | 148 | {ERR_PACK(ERR_LIB_RAND,0,0) ,"random number generator"}, |
| 159 | {ERR_PACK(ERR_LIB_DSO,0,0) ,"DSO support routines"}, | 149 | {ERR_PACK(ERR_LIB_DSO,0,0) ,"DSO support routines"}, |
| 160 | {ERR_PACK(ERR_LIB_ENGINE,0,0) ,"engine routines"}, | 150 | {ERR_PACK(ERR_LIB_ENGINE,0,0) ,"engine routines"}, |
| 151 | {ERR_PACK(ERR_LIB_OCSP,0,0) ,"OCSP routines"}, | ||
| 161 | {0,NULL}, | 152 | {0,NULL}, |
| 162 | }; | 153 | }; |
| 163 | 154 | ||
| @@ -171,7 +162,7 @@ static ERR_STRING_DATA ERR_str_functs[]= | |||
| 171 | {ERR_PACK(0,SYS_F_BIND,0), "bind"}, | 162 | {ERR_PACK(0,SYS_F_BIND,0), "bind"}, |
| 172 | {ERR_PACK(0,SYS_F_LISTEN,0), "listen"}, | 163 | {ERR_PACK(0,SYS_F_LISTEN,0), "listen"}, |
| 173 | {ERR_PACK(0,SYS_F_ACCEPT,0), "accept"}, | 164 | {ERR_PACK(0,SYS_F_ACCEPT,0), "accept"}, |
| 174 | #ifdef WINDOWS | 165 | #ifdef OPENSSL_SYS_WINDOWS |
| 175 | {ERR_PACK(0,SYS_F_WSASTARTUP,0), "WSAstartup"}, | 166 | {ERR_PACK(0,SYS_F_WSASTARTUP,0), "WSAstartup"}, |
| 176 | #endif | 167 | #endif |
| 177 | {ERR_PACK(0,SYS_F_OPENDIR,0), "opendir"}, | 168 | {ERR_PACK(0,SYS_F_OPENDIR,0), "opendir"}, |
| @@ -180,41 +171,325 @@ static ERR_STRING_DATA ERR_str_functs[]= | |||
| 180 | 171 | ||
| 181 | static ERR_STRING_DATA ERR_str_reasons[]= | 172 | static ERR_STRING_DATA ERR_str_reasons[]= |
| 182 | { | 173 | { |
| 183 | {ERR_R_FATAL ,"fatal"}, | ||
| 184 | {ERR_R_SYS_LIB ,"system lib"}, | 174 | {ERR_R_SYS_LIB ,"system lib"}, |
| 185 | {ERR_R_BN_LIB ,"BN lib"}, | 175 | {ERR_R_BN_LIB ,"BN lib"}, |
| 186 | {ERR_R_RSA_LIB ,"RSA lib"}, | 176 | {ERR_R_RSA_LIB ,"RSA lib"}, |
| 187 | {ERR_R_DH_LIB ,"DH lib"}, | 177 | {ERR_R_DH_LIB ,"DH lib"}, |
| 188 | {ERR_R_EVP_LIB ,"EVP lib"}, | 178 | {ERR_R_EVP_LIB ,"EVP lib"}, |
| 189 | {ERR_R_BUF_LIB ,"BUF lib"}, | 179 | {ERR_R_BUF_LIB ,"BUF lib"}, |
| 190 | {ERR_R_BIO_LIB ,"BIO lib"}, | ||
| 191 | {ERR_R_OBJ_LIB ,"OBJ lib"}, | 180 | {ERR_R_OBJ_LIB ,"OBJ lib"}, |
| 192 | {ERR_R_PEM_LIB ,"PEM lib"}, | 181 | {ERR_R_PEM_LIB ,"PEM lib"}, |
| 182 | {ERR_R_DSA_LIB ,"DSA lib"}, | ||
| 193 | {ERR_R_X509_LIB ,"X509 lib"}, | 183 | {ERR_R_X509_LIB ,"X509 lib"}, |
| 194 | {ERR_R_METH_LIB ,"METH lib"}, | ||
| 195 | {ERR_R_ASN1_LIB ,"ASN1 lib"}, | 184 | {ERR_R_ASN1_LIB ,"ASN1 lib"}, |
| 196 | {ERR_R_CONF_LIB ,"CONF lib"}, | 185 | {ERR_R_CONF_LIB ,"CONF lib"}, |
| 186 | {ERR_R_CRYPTO_LIB ,"CRYPTO lib"}, | ||
| 187 | {ERR_R_EC_LIB ,"EC lib"}, | ||
| 197 | {ERR_R_SSL_LIB ,"SSL lib"}, | 188 | {ERR_R_SSL_LIB ,"SSL lib"}, |
| 198 | {ERR_R_PROXY_LIB ,"PROXY lib"}, | ||
| 199 | {ERR_R_BIO_LIB ,"BIO lib"}, | 189 | {ERR_R_BIO_LIB ,"BIO lib"}, |
| 200 | {ERR_R_PKCS7_LIB ,"PKCS7 lib"}, | 190 | {ERR_R_PKCS7_LIB ,"PKCS7 lib"}, |
| 191 | {ERR_R_X509V3_LIB ,"X509V3 lib"}, | ||
| 201 | {ERR_R_PKCS12_LIB ,"PKCS12 lib"}, | 192 | {ERR_R_PKCS12_LIB ,"PKCS12 lib"}, |
| 202 | {ERR_R_MALLOC_FAILURE ,"Malloc failure"}, | 193 | {ERR_R_RAND_LIB ,"RAND lib"}, |
| 203 | {ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED ,"called a function you should not call"}, | 194 | {ERR_R_DSO_LIB ,"DSO lib"}, |
| 204 | {ERR_R_PASSED_NULL_PARAMETER ,"passed a null parameter"}, | 195 | {ERR_R_ENGINE_LIB ,"ENGINE lib"}, |
| 196 | {ERR_R_OCSP_LIB ,"OCSP lib"}, | ||
| 197 | |||
| 205 | {ERR_R_NESTED_ASN1_ERROR ,"nested asn1 error"}, | 198 | {ERR_R_NESTED_ASN1_ERROR ,"nested asn1 error"}, |
| 206 | {ERR_R_BAD_ASN1_OBJECT_HEADER ,"bad asn1 object header"}, | 199 | {ERR_R_BAD_ASN1_OBJECT_HEADER ,"bad asn1 object header"}, |
| 207 | {ERR_R_BAD_GET_ASN1_OBJECT_CALL ,"bad get asn1 object call"}, | 200 | {ERR_R_BAD_GET_ASN1_OBJECT_CALL ,"bad get asn1 object call"}, |
| 208 | {ERR_R_EXPECTING_AN_ASN1_SEQUENCE ,"expecting an asn1 sequence"}, | 201 | {ERR_R_EXPECTING_AN_ASN1_SEQUENCE ,"expecting an asn1 sequence"}, |
| 209 | {ERR_R_ASN1_LENGTH_MISMATCH ,"asn1 length mismatch"}, | 202 | {ERR_R_ASN1_LENGTH_MISMATCH ,"asn1 length mismatch"}, |
| 210 | {ERR_R_MISSING_ASN1_EOS ,"missing asn1 eos"}, | 203 | {ERR_R_MISSING_ASN1_EOS ,"missing asn1 eos"}, |
| 211 | {ERR_R_DSO_LIB ,"DSO lib"}, | 204 | |
| 212 | {ERR_R_ENGINE_LIB ,"ENGINE lib"}, | 205 | {ERR_R_FATAL ,"fatal"}, |
| 206 | {ERR_R_MALLOC_FAILURE ,"malloc failure"}, | ||
| 207 | {ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED ,"called a function you should not call"}, | ||
| 208 | {ERR_R_PASSED_NULL_PARAMETER ,"passed a null parameter"}, | ||
| 209 | {ERR_R_INTERNAL_ERROR ,"internal error"}, | ||
| 213 | 210 | ||
| 214 | {0,NULL}, | 211 | {0,NULL}, |
| 215 | }; | 212 | }; |
| 216 | 213 | ||
| 217 | 214 | ||
| 215 | /* Define the predeclared (but externally opaque) "ERR_FNS" type */ | ||
| 216 | struct st_ERR_FNS | ||
| 217 | { | ||
| 218 | /* Works on the "error_hash" string table */ | ||
| 219 | LHASH *(*cb_err_get)(int create); | ||
| 220 | void (*cb_err_del)(void); | ||
| 221 | ERR_STRING_DATA *(*cb_err_get_item)(const ERR_STRING_DATA *); | ||
| 222 | ERR_STRING_DATA *(*cb_err_set_item)(ERR_STRING_DATA *); | ||
| 223 | ERR_STRING_DATA *(*cb_err_del_item)(ERR_STRING_DATA *); | ||
| 224 | /* Works on the "thread_hash" error-state table */ | ||
| 225 | LHASH *(*cb_thread_get)(int create); | ||
| 226 | ERR_STATE *(*cb_thread_get_item)(const ERR_STATE *); | ||
| 227 | ERR_STATE *(*cb_thread_set_item)(ERR_STATE *); | ||
| 228 | void (*cb_thread_del_item)(const ERR_STATE *); | ||
| 229 | /* Returns the next available error "library" numbers */ | ||
| 230 | int (*cb_get_next_lib)(void); | ||
| 231 | }; | ||
| 232 | |||
| 233 | /* Predeclarations of the "err_defaults" functions */ | ||
| 234 | static LHASH *int_err_get(int create); | ||
| 235 | static void int_err_del(void); | ||
| 236 | static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *); | ||
| 237 | static ERR_STRING_DATA *int_err_set_item(ERR_STRING_DATA *); | ||
| 238 | static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *); | ||
| 239 | static LHASH *int_thread_get(int create); | ||
| 240 | static ERR_STATE *int_thread_get_item(const ERR_STATE *); | ||
| 241 | static ERR_STATE *int_thread_set_item(ERR_STATE *); | ||
| 242 | static void int_thread_del_item(const ERR_STATE *); | ||
| 243 | static int int_err_get_next_lib(void); | ||
| 244 | /* The static ERR_FNS table using these defaults functions */ | ||
| 245 | static const ERR_FNS err_defaults = | ||
| 246 | { | ||
| 247 | int_err_get, | ||
| 248 | int_err_del, | ||
| 249 | int_err_get_item, | ||
| 250 | int_err_set_item, | ||
| 251 | int_err_del_item, | ||
| 252 | int_thread_get, | ||
| 253 | int_thread_get_item, | ||
| 254 | int_thread_set_item, | ||
| 255 | int_thread_del_item, | ||
| 256 | int_err_get_next_lib | ||
| 257 | }; | ||
| 258 | |||
| 259 | /* The replacable table of ERR_FNS functions we use at run-time */ | ||
| 260 | static const ERR_FNS *err_fns = NULL; | ||
| 261 | |||
| 262 | /* Eg. rather than using "err_get()", use "ERRFN(err_get)()". */ | ||
| 263 | #define ERRFN(a) err_fns->cb_##a | ||
| 264 | |||
| 265 | /* The internal state used by "err_defaults" - as such, the setting, reading, | ||
| 266 | * creating, and deleting of this data should only be permitted via the | ||
| 267 | * "err_defaults" functions. This way, a linked module can completely defer all | ||
| 268 | * ERR state operation (together with requisite locking) to the implementations | ||
| 269 | * and state in the loading application. */ | ||
| 270 | static LHASH *int_error_hash = NULL; | ||
| 271 | static LHASH *int_thread_hash = NULL; | ||
| 272 | static int int_err_library_number= ERR_LIB_USER; | ||
| 273 | |||
| 274 | /* Internal function that checks whether "err_fns" is set and if not, sets it to | ||
| 275 | * the defaults. */ | ||
| 276 | static void err_fns_check(void) | ||
| 277 | { | ||
| 278 | if (err_fns) return; | ||
| 279 | |||
| 280 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | ||
| 281 | if (!err_fns) | ||
| 282 | err_fns = &err_defaults; | ||
| 283 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | ||
| 284 | } | ||
| 285 | |||
| 286 | /* API functions to get or set the underlying ERR functions. */ | ||
| 287 | |||
| 288 | const ERR_FNS *ERR_get_implementation(void) | ||
| 289 | { | ||
| 290 | err_fns_check(); | ||
| 291 | return err_fns; | ||
| 292 | } | ||
| 293 | |||
| 294 | int ERR_set_implementation(const ERR_FNS *fns) | ||
| 295 | { | ||
| 296 | int ret = 0; | ||
| 297 | |||
| 298 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | ||
| 299 | /* It's too late if 'err_fns' is non-NULL. BTW: not much point setting | ||
| 300 | * an error is there?! */ | ||
| 301 | if (!err_fns) | ||
| 302 | { | ||
| 303 | err_fns = fns; | ||
| 304 | ret = 1; | ||
| 305 | } | ||
| 306 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | ||
| 307 | return ret; | ||
| 308 | } | ||
| 309 | |||
| 310 | /* These are the callbacks provided to "lh_new()" when creating the LHASH tables | ||
| 311 | * internal to the "err_defaults" implementation. */ | ||
| 312 | |||
| 313 | /* static unsigned long err_hash(ERR_STRING_DATA *a); */ | ||
| 314 | static unsigned long err_hash(const void *a_void); | ||
| 315 | /* static int err_cmp(ERR_STRING_DATA *a, ERR_STRING_DATA *b); */ | ||
| 316 | static int err_cmp(const void *a_void, const void *b_void); | ||
| 317 | /* static unsigned long pid_hash(ERR_STATE *pid); */ | ||
| 318 | static unsigned long pid_hash(const void *pid_void); | ||
| 319 | /* static int pid_cmp(ERR_STATE *a,ERR_STATE *pid); */ | ||
| 320 | static int pid_cmp(const void *a_void,const void *pid_void); | ||
| 321 | static unsigned long get_error_values(int inc,int top,const char **file,int *line, | ||
| 322 | const char **data,int *flags); | ||
| 323 | |||
| 324 | /* The internal functions used in the "err_defaults" implementation */ | ||
| 325 | |||
| 326 | static LHASH *int_err_get(int create) | ||
| 327 | { | ||
| 328 | LHASH *ret = NULL; | ||
| 329 | |||
| 330 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | ||
| 331 | if (!int_error_hash && create) | ||
| 332 | { | ||
| 333 | CRYPTO_push_info("int_err_get (err.c)"); | ||
| 334 | int_error_hash = lh_new(err_hash, err_cmp); | ||
| 335 | CRYPTO_pop_info(); | ||
| 336 | } | ||
| 337 | if (int_error_hash) | ||
| 338 | ret = int_error_hash; | ||
| 339 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | ||
| 340 | |||
| 341 | return ret; | ||
| 342 | } | ||
| 343 | |||
| 344 | static void int_err_del(void) | ||
| 345 | { | ||
| 346 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | ||
| 347 | if (int_error_hash) | ||
| 348 | { | ||
| 349 | lh_free(int_error_hash); | ||
| 350 | int_error_hash = NULL; | ||
| 351 | } | ||
| 352 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | ||
| 353 | } | ||
| 354 | |||
| 355 | static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *d) | ||
| 356 | { | ||
| 357 | ERR_STRING_DATA *p; | ||
| 358 | LHASH *hash; | ||
| 359 | |||
| 360 | err_fns_check(); | ||
| 361 | hash = ERRFN(err_get)(0); | ||
| 362 | if (!hash) | ||
| 363 | return NULL; | ||
| 364 | |||
| 365 | CRYPTO_r_lock(CRYPTO_LOCK_ERR); | ||
| 366 | p = (ERR_STRING_DATA *)lh_retrieve(hash, d); | ||
| 367 | CRYPTO_r_unlock(CRYPTO_LOCK_ERR); | ||
| 368 | |||
| 369 | return p; | ||
| 370 | } | ||
| 371 | |||
| 372 | static ERR_STRING_DATA *int_err_set_item(ERR_STRING_DATA *d) | ||
| 373 | { | ||
| 374 | ERR_STRING_DATA *p; | ||
| 375 | LHASH *hash; | ||
| 376 | |||
| 377 | err_fns_check(); | ||
| 378 | hash = ERRFN(err_get)(1); | ||
| 379 | if (!hash) | ||
| 380 | return NULL; | ||
| 381 | |||
| 382 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | ||
| 383 | p = (ERR_STRING_DATA *)lh_insert(hash, d); | ||
| 384 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | ||
| 385 | |||
| 386 | return p; | ||
| 387 | } | ||
| 388 | |||
| 389 | static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *d) | ||
| 390 | { | ||
| 391 | ERR_STRING_DATA *p; | ||
| 392 | LHASH *hash; | ||
| 393 | |||
| 394 | err_fns_check(); | ||
| 395 | hash = ERRFN(err_get)(0); | ||
| 396 | if (!hash) | ||
| 397 | return NULL; | ||
| 398 | |||
| 399 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | ||
| 400 | p = (ERR_STRING_DATA *)lh_delete(hash, d); | ||
| 401 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | ||
| 402 | |||
| 403 | return p; | ||
| 404 | } | ||
| 405 | |||
| 406 | static LHASH *int_thread_get(int create) | ||
| 407 | { | ||
| 408 | LHASH *ret = NULL; | ||
| 409 | |||
| 410 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | ||
| 411 | if (!int_thread_hash && create) | ||
| 412 | { | ||
| 413 | CRYPTO_push_info("int_thread_get (err.c)"); | ||
| 414 | int_thread_hash = lh_new(pid_hash, pid_cmp); | ||
| 415 | CRYPTO_pop_info(); | ||
| 416 | } | ||
| 417 | if (int_thread_hash) | ||
| 418 | ret = int_thread_hash; | ||
| 419 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | ||
| 420 | return ret; | ||
| 421 | } | ||
| 422 | |||
| 423 | static ERR_STATE *int_thread_get_item(const ERR_STATE *d) | ||
| 424 | { | ||
| 425 | ERR_STATE *p; | ||
| 426 | LHASH *hash; | ||
| 427 | |||
| 428 | err_fns_check(); | ||
| 429 | hash = ERRFN(thread_get)(0); | ||
| 430 | if (!hash) | ||
| 431 | return NULL; | ||
| 432 | |||
| 433 | CRYPTO_r_lock(CRYPTO_LOCK_ERR); | ||
| 434 | p = (ERR_STATE *)lh_retrieve(hash, d); | ||
| 435 | CRYPTO_r_unlock(CRYPTO_LOCK_ERR); | ||
| 436 | |||
| 437 | return p; | ||
| 438 | } | ||
| 439 | |||
| 440 | static ERR_STATE *int_thread_set_item(ERR_STATE *d) | ||
| 441 | { | ||
| 442 | ERR_STATE *p; | ||
| 443 | LHASH *hash; | ||
| 444 | |||
| 445 | err_fns_check(); | ||
| 446 | hash = ERRFN(thread_get)(1); | ||
| 447 | if (!hash) | ||
| 448 | return NULL; | ||
| 449 | |||
| 450 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | ||
| 451 | p = (ERR_STATE *)lh_insert(hash, d); | ||
| 452 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | ||
| 453 | |||
| 454 | return p; | ||
| 455 | } | ||
| 456 | |||
| 457 | static void int_thread_del_item(const ERR_STATE *d) | ||
| 458 | { | ||
| 459 | ERR_STATE *p; | ||
| 460 | LHASH *hash; | ||
| 461 | |||
| 462 | err_fns_check(); | ||
| 463 | hash = ERRFN(thread_get)(0); | ||
| 464 | if (!hash) | ||
| 465 | return; | ||
| 466 | |||
| 467 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | ||
| 468 | p = (ERR_STATE *)lh_delete(hash, d); | ||
| 469 | /* make sure we don't leak memory */ | ||
| 470 | if (int_thread_hash && (lh_num_items(int_thread_hash) == 0)) | ||
| 471 | { | ||
| 472 | lh_free(int_thread_hash); | ||
| 473 | int_thread_hash = NULL; | ||
| 474 | } | ||
| 475 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | ||
| 476 | |||
| 477 | if (p) | ||
| 478 | ERR_STATE_free(p); | ||
| 479 | } | ||
| 480 | |||
| 481 | static int int_err_get_next_lib(void) | ||
| 482 | { | ||
| 483 | int ret; | ||
| 484 | |||
| 485 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | ||
| 486 | ret = int_err_library_number++; | ||
| 487 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | ||
| 488 | |||
| 489 | return ret; | ||
| 490 | } | ||
| 491 | |||
| 492 | |||
| 218 | #define NUM_SYS_STR_REASONS 127 | 493 | #define NUM_SYS_STR_REASONS 127 |
| 219 | #define LEN_SYS_STR_REASON 32 | 494 | #define LEN_SYS_STR_REASON 32 |
| 220 | 495 | ||
| @@ -233,8 +508,11 @@ static void build_SYS_str_reasons() | |||
| 233 | /* OPENSSL_malloc cannot be used here, use static storage instead */ | 508 | /* OPENSSL_malloc cannot be used here, use static storage instead */ |
| 234 | static char strerror_tab[NUM_SYS_STR_REASONS][LEN_SYS_STR_REASON]; | 509 | static char strerror_tab[NUM_SYS_STR_REASONS][LEN_SYS_STR_REASON]; |
| 235 | int i; | 510 | int i; |
| 511 | static int init = 1; | ||
| 512 | |||
| 513 | if (!init) return; | ||
| 236 | 514 | ||
| 237 | CRYPTO_w_lock(CRYPTO_LOCK_ERR_HASH); | 515 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); |
| 238 | 516 | ||
| 239 | for (i = 1; i <= NUM_SYS_STR_REASONS; i++) | 517 | for (i = 1; i <= NUM_SYS_STR_REASONS; i++) |
| 240 | { | 518 | { |
| @@ -259,7 +537,9 @@ static void build_SYS_str_reasons() | |||
| 259 | /* Now we still have SYS_str_reasons[NUM_SYS_STR_REASONS] = {0, NULL}, | 537 | /* Now we still have SYS_str_reasons[NUM_SYS_STR_REASONS] = {0, NULL}, |
| 260 | * as required by ERR_load_strings. */ | 538 | * as required by ERR_load_strings. */ |
| 261 | 539 | ||
| 262 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR_HASH); | 540 | init = 0; |
| 541 | |||
| 542 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | ||
| 263 | } | 543 | } |
| 264 | #endif | 544 | #endif |
| 265 | 545 | ||
| @@ -276,7 +556,7 @@ static void ERR_STATE_free(ERR_STATE *s) | |||
| 276 | { | 556 | { |
| 277 | int i; | 557 | int i; |
| 278 | 558 | ||
| 279 | if(s == NULL) | 559 | if (s == NULL) |
| 280 | return; | 560 | return; |
| 281 | 561 | ||
| 282 | for (i=0; i<ERR_NUM_ERRORS; i++) | 562 | for (i=0; i<ERR_NUM_ERRORS; i++) |
| @@ -288,66 +568,46 @@ static void ERR_STATE_free(ERR_STATE *s) | |||
| 288 | 568 | ||
| 289 | void ERR_load_ERR_strings(void) | 569 | void ERR_load_ERR_strings(void) |
| 290 | { | 570 | { |
| 291 | static int init=1; | 571 | err_fns_check(); |
| 572 | #ifndef OPENSSL_NO_ERR | ||
| 573 | err_load_strings(0,ERR_str_libraries); | ||
| 574 | err_load_strings(0,ERR_str_reasons); | ||
| 575 | err_load_strings(ERR_LIB_SYS,ERR_str_functs); | ||
| 576 | build_SYS_str_reasons(); | ||
| 577 | err_load_strings(ERR_LIB_SYS,SYS_str_reasons); | ||
| 578 | #endif | ||
| 579 | } | ||
| 292 | 580 | ||
| 293 | if (init) | 581 | static void err_load_strings(int lib, ERR_STRING_DATA *str) |
| 582 | { | ||
| 583 | while (str->error) | ||
| 294 | { | 584 | { |
| 295 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | 585 | str->error|=ERR_PACK(lib,0,0); |
| 296 | if (init == 0) | 586 | ERRFN(err_set_item)(str); |
| 297 | { | 587 | str++; |
| 298 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | ||
| 299 | return; | ||
| 300 | } | ||
| 301 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | ||
| 302 | |||
| 303 | #ifndef NO_ERR | ||
| 304 | ERR_load_strings(0,ERR_str_libraries); | ||
| 305 | ERR_load_strings(0,ERR_str_reasons); | ||
| 306 | ERR_load_strings(ERR_LIB_SYS,ERR_str_functs); | ||
| 307 | build_SYS_str_reasons(); | ||
| 308 | ERR_load_strings(ERR_LIB_SYS,SYS_str_reasons); | ||
| 309 | #endif | ||
| 310 | init=0; | ||
| 311 | } | 588 | } |
| 312 | } | 589 | } |
| 313 | 590 | ||
| 314 | void ERR_load_strings(int lib, ERR_STRING_DATA *str) | 591 | void ERR_load_strings(int lib, ERR_STRING_DATA *str) |
| 315 | { | 592 | { |
| 316 | if (error_hash == NULL) | 593 | ERR_load_ERR_strings(); |
| 317 | { | 594 | err_load_strings(lib, str); |
| 318 | CRYPTO_w_lock(CRYPTO_LOCK_ERR_HASH); | 595 | } |
| 319 | error_hash=lh_new(err_hash,err_cmp); | ||
| 320 | if (error_hash == NULL) | ||
| 321 | { | ||
| 322 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR_HASH); | ||
| 323 | return; | ||
| 324 | } | ||
| 325 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR_HASH); | ||
| 326 | |||
| 327 | ERR_load_ERR_strings(); | ||
| 328 | } | ||
| 329 | 596 | ||
| 330 | CRYPTO_w_lock(CRYPTO_LOCK_ERR_HASH); | 597 | void ERR_unload_strings(int lib, ERR_STRING_DATA *str) |
| 598 | { | ||
| 331 | while (str->error) | 599 | while (str->error) |
| 332 | { | 600 | { |
| 333 | str->error|=ERR_PACK(lib,0,0); | 601 | str->error|=ERR_PACK(lib,0,0); |
| 334 | lh_insert(error_hash,str); | 602 | ERRFN(err_del_item)(str); |
| 335 | str++; | 603 | str++; |
| 336 | } | 604 | } |
| 337 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR_HASH); | ||
| 338 | } | 605 | } |
| 339 | 606 | ||
| 340 | void ERR_free_strings(void) | 607 | void ERR_free_strings(void) |
| 341 | { | 608 | { |
| 342 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | 609 | err_fns_check(); |
| 343 | 610 | ERRFN(err_del)(); | |
| 344 | if (error_hash != NULL) | ||
| 345 | { | ||
| 346 | lh_free(error_hash); | ||
| 347 | error_hash=NULL; | ||
| 348 | } | ||
| 349 | |||
| 350 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | ||
| 351 | } | 611 | } |
| 352 | 612 | ||
| 353 | /********************************************************/ | 613 | /********************************************************/ |
| @@ -406,30 +666,40 @@ void ERR_clear_error(void) | |||
| 406 | 666 | ||
| 407 | 667 | ||
| 408 | unsigned long ERR_get_error(void) | 668 | unsigned long ERR_get_error(void) |
| 409 | { return(get_error_values(1,NULL,NULL,NULL,NULL)); } | 669 | { return(get_error_values(1,0,NULL,NULL,NULL,NULL)); } |
| 410 | 670 | ||
| 411 | unsigned long ERR_get_error_line(const char **file, | 671 | unsigned long ERR_get_error_line(const char **file, |
| 412 | int *line) | 672 | int *line) |
| 413 | { return(get_error_values(1,file,line,NULL,NULL)); } | 673 | { return(get_error_values(1,0,file,line,NULL,NULL)); } |
| 414 | 674 | ||
| 415 | unsigned long ERR_get_error_line_data(const char **file, int *line, | 675 | unsigned long ERR_get_error_line_data(const char **file, int *line, |
| 416 | const char **data, int *flags) | 676 | const char **data, int *flags) |
| 417 | { return(get_error_values(1,file,line, | 677 | { return(get_error_values(1,0,file,line,data,flags)); } |
| 418 | data,flags)); } | 678 | |
| 419 | 679 | ||
| 420 | unsigned long ERR_peek_error(void) | 680 | unsigned long ERR_peek_error(void) |
| 421 | { return(get_error_values(0,NULL,NULL,NULL,NULL)); } | 681 | { return(get_error_values(0,0,NULL,NULL,NULL,NULL)); } |
| 422 | 682 | ||
| 423 | unsigned long ERR_peek_error_line(const char **file, | 683 | unsigned long ERR_peek_error_line(const char **file, int *line) |
| 424 | int *line) | 684 | { return(get_error_values(0,0,file,line,NULL,NULL)); } |
| 425 | { return(get_error_values(0,file,line,NULL,NULL)); } | ||
| 426 | 685 | ||
| 427 | unsigned long ERR_peek_error_line_data(const char **file, int *line, | 686 | unsigned long ERR_peek_error_line_data(const char **file, int *line, |
| 428 | const char **data, int *flags) | 687 | const char **data, int *flags) |
| 429 | { return(get_error_values(0,file,line, | 688 | { return(get_error_values(0,0,file,line,data,flags)); } |
| 430 | data,flags)); } | 689 | |
| 690 | |||
| 691 | unsigned long ERR_peek_last_error(void) | ||
| 692 | { return(get_error_values(0,1,NULL,NULL,NULL,NULL)); } | ||
| 693 | |||
| 694 | unsigned long ERR_peek_last_error_line(const char **file, int *line) | ||
| 695 | { return(get_error_values(0,1,file,line,NULL,NULL)); } | ||
| 696 | |||
| 697 | unsigned long ERR_peek_last_error_line_data(const char **file, int *line, | ||
| 698 | const char **data, int *flags) | ||
| 699 | { return(get_error_values(0,1,file,line,data,flags)); } | ||
| 700 | |||
| 431 | 701 | ||
| 432 | static unsigned long get_error_values(int inc, const char **file, int *line, | 702 | static unsigned long get_error_values(int inc, int top, const char **file, int *line, |
| 433 | const char **data, int *flags) | 703 | const char **data, int *flags) |
| 434 | { | 704 | { |
| 435 | int i=0; | 705 | int i=0; |
| @@ -438,8 +708,21 @@ static unsigned long get_error_values(int inc, const char **file, int *line, | |||
| 438 | 708 | ||
| 439 | es=ERR_get_state(); | 709 | es=ERR_get_state(); |
| 440 | 710 | ||
| 441 | if (es->bottom == es->top) return(0); | 711 | if (inc && top) |
| 442 | i=(es->bottom+1)%ERR_NUM_ERRORS; | 712 | { |
| 713 | if (file) *file = ""; | ||
| 714 | if (line) *line = 0; | ||
| 715 | if (data) *data = ""; | ||
| 716 | if (flags) *flags = 0; | ||
| 717 | |||
| 718 | return ERR_R_INTERNAL_ERROR; | ||
| 719 | } | ||
| 720 | |||
| 721 | if (es->bottom == es->top) return 0; | ||
| 722 | if (top) | ||
| 723 | i=es->top; /* last error */ | ||
| 724 | else | ||
| 725 | i=(es->bottom+1)%ERR_NUM_ERRORS; /* first error */ | ||
| 443 | 726 | ||
| 444 | ret=es->err_buffer[i]; | 727 | ret=es->err_buffer[i]; |
| 445 | if (inc) | 728 | if (inc) |
| @@ -482,7 +765,7 @@ static unsigned long get_error_values(int inc, const char **file, int *line, | |||
| 482 | if (flags != NULL) *flags=es->err_data_flags[i]; | 765 | if (flags != NULL) *flags=es->err_data_flags[i]; |
| 483 | } | 766 | } |
| 484 | } | 767 | } |
| 485 | return(ret); | 768 | return ret; |
| 486 | } | 769 | } |
| 487 | 770 | ||
| 488 | void ERR_error_string_n(unsigned long e, char *buf, size_t len) | 771 | void ERR_error_string_n(unsigned long e, char *buf, size_t len) |
| @@ -544,58 +827,43 @@ char *ERR_error_string(unsigned long e, char *ret) | |||
| 544 | if (ret == NULL) ret=buf; | 827 | if (ret == NULL) ret=buf; |
| 545 | ERR_error_string_n(e, ret, 256); | 828 | ERR_error_string_n(e, ret, 256); |
| 546 | 829 | ||
| 547 | return(ret); | 830 | return ret; |
| 548 | } | 831 | } |
| 549 | 832 | ||
| 550 | LHASH *ERR_get_string_table(void) | 833 | LHASH *ERR_get_string_table(void) |
| 551 | { | 834 | { |
| 552 | return(error_hash); | 835 | err_fns_check(); |
| 836 | return ERRFN(err_get)(0); | ||
| 553 | } | 837 | } |
| 554 | 838 | ||
| 555 | /* not thread-safe */ | ||
| 556 | LHASH *ERR_get_err_state_table(void) | 839 | LHASH *ERR_get_err_state_table(void) |
| 557 | { | 840 | { |
| 558 | return(thread_hash); | 841 | err_fns_check(); |
| 842 | return ERRFN(thread_get)(0); | ||
| 559 | } | 843 | } |
| 560 | 844 | ||
| 561 | const char *ERR_lib_error_string(unsigned long e) | 845 | const char *ERR_lib_error_string(unsigned long e) |
| 562 | { | 846 | { |
| 563 | ERR_STRING_DATA d,*p=NULL; | 847 | ERR_STRING_DATA d,*p; |
| 564 | unsigned long l; | 848 | unsigned long l; |
| 565 | 849 | ||
| 850 | err_fns_check(); | ||
| 566 | l=ERR_GET_LIB(e); | 851 | l=ERR_GET_LIB(e); |
| 567 | 852 | d.error=ERR_PACK(l,0,0); | |
| 568 | CRYPTO_w_lock(CRYPTO_LOCK_ERR_HASH); | 853 | p=ERRFN(err_get_item)(&d); |
| 569 | |||
| 570 | if (error_hash != NULL) | ||
| 571 | { | ||
| 572 | d.error=ERR_PACK(l,0,0); | ||
| 573 | p=(ERR_STRING_DATA *)lh_retrieve(error_hash,&d); | ||
| 574 | } | ||
| 575 | |||
| 576 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR_HASH); | ||
| 577 | |||
| 578 | return((p == NULL)?NULL:p->string); | 854 | return((p == NULL)?NULL:p->string); |
| 579 | } | 855 | } |
| 580 | 856 | ||
| 581 | const char *ERR_func_error_string(unsigned long e) | 857 | const char *ERR_func_error_string(unsigned long e) |
| 582 | { | 858 | { |
| 583 | ERR_STRING_DATA d,*p=NULL; | 859 | ERR_STRING_DATA d,*p; |
| 584 | unsigned long l,f; | 860 | unsigned long l,f; |
| 585 | 861 | ||
| 862 | err_fns_check(); | ||
| 586 | l=ERR_GET_LIB(e); | 863 | l=ERR_GET_LIB(e); |
| 587 | f=ERR_GET_FUNC(e); | 864 | f=ERR_GET_FUNC(e); |
| 588 | 865 | d.error=ERR_PACK(l,f,0); | |
| 589 | CRYPTO_w_lock(CRYPTO_LOCK_ERR_HASH); | 866 | p=ERRFN(err_get_item)(&d); |
| 590 | |||
| 591 | if (error_hash != NULL) | ||
| 592 | { | ||
| 593 | d.error=ERR_PACK(l,f,0); | ||
| 594 | p=(ERR_STRING_DATA *)lh_retrieve(error_hash,&d); | ||
| 595 | } | ||
| 596 | |||
| 597 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR_HASH); | ||
| 598 | |||
| 599 | return((p == NULL)?NULL:p->string); | 867 | return((p == NULL)?NULL:p->string); |
| 600 | } | 868 | } |
| 601 | 869 | ||
| @@ -604,93 +872,73 @@ const char *ERR_reason_error_string(unsigned long e) | |||
| 604 | ERR_STRING_DATA d,*p=NULL; | 872 | ERR_STRING_DATA d,*p=NULL; |
| 605 | unsigned long l,r; | 873 | unsigned long l,r; |
| 606 | 874 | ||
| 875 | err_fns_check(); | ||
| 607 | l=ERR_GET_LIB(e); | 876 | l=ERR_GET_LIB(e); |
| 608 | r=ERR_GET_REASON(e); | 877 | r=ERR_GET_REASON(e); |
| 609 | 878 | d.error=ERR_PACK(l,0,r); | |
| 610 | CRYPTO_w_lock(CRYPTO_LOCK_ERR_HASH); | 879 | p=ERRFN(err_get_item)(&d); |
| 611 | 880 | if (!p) | |
| 612 | if (error_hash != NULL) | ||
| 613 | { | 881 | { |
| 614 | d.error=ERR_PACK(l,0,r); | 882 | d.error=ERR_PACK(0,0,r); |
| 615 | p=(ERR_STRING_DATA *)lh_retrieve(error_hash,&d); | 883 | p=ERRFN(err_get_item)(&d); |
| 616 | if (p == NULL) | ||
| 617 | { | ||
| 618 | d.error=ERR_PACK(0,0,r); | ||
| 619 | p=(ERR_STRING_DATA *)lh_retrieve(error_hash,&d); | ||
| 620 | } | ||
| 621 | } | 884 | } |
| 622 | |||
| 623 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR_HASH); | ||
| 624 | |||
| 625 | return((p == NULL)?NULL:p->string); | 885 | return((p == NULL)?NULL:p->string); |
| 626 | } | 886 | } |
| 627 | 887 | ||
| 628 | static unsigned long err_hash(ERR_STRING_DATA *a) | 888 | /* static unsigned long err_hash(ERR_STRING_DATA *a) */ |
| 889 | static unsigned long err_hash(const void *a_void) | ||
| 629 | { | 890 | { |
| 630 | unsigned long ret,l; | 891 | unsigned long ret,l; |
| 631 | 892 | ||
| 632 | l=a->error; | 893 | l=((ERR_STRING_DATA *)a_void)->error; |
| 633 | ret=l^ERR_GET_LIB(l)^ERR_GET_FUNC(l); | 894 | ret=l^ERR_GET_LIB(l)^ERR_GET_FUNC(l); |
| 634 | return(ret^ret%19*13); | 895 | return(ret^ret%19*13); |
| 635 | } | 896 | } |
| 636 | 897 | ||
| 637 | static int err_cmp(ERR_STRING_DATA *a, ERR_STRING_DATA *b) | 898 | /* static int err_cmp(ERR_STRING_DATA *a, ERR_STRING_DATA *b) */ |
| 899 | static int err_cmp(const void *a_void, const void *b_void) | ||
| 638 | { | 900 | { |
| 639 | return((int)(a->error-b->error)); | 901 | return((int)(((ERR_STRING_DATA *)a_void)->error - |
| 902 | ((ERR_STRING_DATA *)b_void)->error)); | ||
| 640 | } | 903 | } |
| 641 | 904 | ||
| 642 | static unsigned long pid_hash(ERR_STATE *a) | 905 | /* static unsigned long pid_hash(ERR_STATE *a) */ |
| 906 | static unsigned long pid_hash(const void *a_void) | ||
| 643 | { | 907 | { |
| 644 | return(a->pid*13); | 908 | return(((ERR_STATE *)a_void)->pid*13); |
| 645 | } | 909 | } |
| 646 | 910 | ||
| 647 | static int pid_cmp(ERR_STATE *a, ERR_STATE *b) | 911 | /* static int pid_cmp(ERR_STATE *a, ERR_STATE *b) */ |
| 912 | static int pid_cmp(const void *a_void, const void *b_void) | ||
| 648 | { | 913 | { |
| 649 | return((int)((long)a->pid - (long)b->pid)); | 914 | return((int)((long)((ERR_STATE *)a_void)->pid - |
| 915 | (long)((ERR_STATE *)b_void)->pid)); | ||
| 650 | } | 916 | } |
| 651 | 917 | ||
| 652 | void ERR_remove_state(unsigned long pid) | 918 | void ERR_remove_state(unsigned long pid) |
| 653 | { | 919 | { |
| 654 | ERR_STATE *p = NULL,tmp; | 920 | ERR_STATE tmp; |
| 655 | 921 | ||
| 656 | if (thread_hash == NULL) | 922 | err_fns_check(); |
| 657 | return; | ||
| 658 | if (pid == 0) | 923 | if (pid == 0) |
| 659 | pid=(unsigned long)CRYPTO_thread_id(); | 924 | pid=(unsigned long)CRYPTO_thread_id(); |
| 660 | tmp.pid=pid; | 925 | tmp.pid=pid; |
| 661 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | 926 | /* thread_del_item automatically destroys the LHASH if the number of |
| 662 | if (thread_hash) | 927 | * items reaches zero. */ |
| 663 | { | 928 | ERRFN(thread_del_item)(&tmp); |
| 664 | p=(ERR_STATE *)lh_delete(thread_hash,&tmp); | ||
| 665 | if (lh_num_items(thread_hash) == 0) | ||
| 666 | { | ||
| 667 | /* make sure we don't leak memory */ | ||
| 668 | lh_free(thread_hash); | ||
| 669 | thread_hash = NULL; | ||
| 670 | } | ||
| 671 | } | ||
| 672 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | ||
| 673 | |||
| 674 | if (p != NULL) ERR_STATE_free(p); | ||
| 675 | } | 929 | } |
| 676 | 930 | ||
| 677 | ERR_STATE *ERR_get_state(void) | 931 | ERR_STATE *ERR_get_state(void) |
| 678 | { | 932 | { |
| 679 | static ERR_STATE fallback; | 933 | static ERR_STATE fallback; |
| 680 | ERR_STATE *ret=NULL,tmp,*tmpp=NULL; | 934 | ERR_STATE *ret,tmp,*tmpp=NULL; |
| 681 | int thread_state_exists; | ||
| 682 | int i; | 935 | int i; |
| 683 | unsigned long pid; | 936 | unsigned long pid; |
| 684 | 937 | ||
| 938 | err_fns_check(); | ||
| 685 | pid=(unsigned long)CRYPTO_thread_id(); | 939 | pid=(unsigned long)CRYPTO_thread_id(); |
| 686 | 940 | tmp.pid=pid; | |
| 687 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | 941 | ret=ERRFN(thread_get_item)(&tmp); |
| 688 | if (thread_hash != NULL) | ||
| 689 | { | ||
| 690 | tmp.pid=pid; | ||
| 691 | ret=(ERR_STATE *)lh_retrieve(thread_hash,&tmp); | ||
| 692 | } | ||
| 693 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | ||
| 694 | 942 | ||
| 695 | /* ret == the error state, if NULL, make a new one */ | 943 | /* ret == the error state, if NULL, make a new one */ |
| 696 | if (ret == NULL) | 944 | if (ret == NULL) |
| @@ -705,42 +953,25 @@ ERR_STATE *ERR_get_state(void) | |||
| 705 | ret->err_data[i]=NULL; | 953 | ret->err_data[i]=NULL; |
| 706 | ret->err_data_flags[i]=0; | 954 | ret->err_data_flags[i]=0; |
| 707 | } | 955 | } |
| 708 | 956 | tmpp = ERRFN(thread_set_item)(ret); | |
| 709 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | 957 | /* To check if insertion failed, do a get. */ |
| 710 | 958 | if (ERRFN(thread_get_item)(ret) != ret) | |
| 711 | /* no entry yet in thread_hash for current thread - | ||
| 712 | * thus, it may have changed since we last looked at it */ | ||
| 713 | if (thread_hash == NULL) | ||
| 714 | thread_hash = lh_new(pid_hash, pid_cmp); | ||
| 715 | if (thread_hash == NULL) | ||
| 716 | thread_state_exists = 0; /* allocation error */ | ||
| 717 | else | ||
| 718 | { | ||
| 719 | tmpp=(ERR_STATE *)lh_insert(thread_hash,ret); | ||
| 720 | thread_state_exists = 1; | ||
| 721 | } | ||
| 722 | |||
| 723 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | ||
| 724 | |||
| 725 | if (!thread_state_exists) | ||
| 726 | { | 959 | { |
| 727 | ERR_STATE_free(ret); /* could not insert it */ | 960 | ERR_STATE_free(ret); /* could not insert it */ |
| 728 | return(&fallback); | 961 | return(&fallback); |
| 729 | } | 962 | } |
| 730 | 963 | /* If a race occured in this function and we came second, tmpp | |
| 731 | if (tmpp != NULL) /* old entry - should not happen */ | 964 | * is the first one that we just replaced. */ |
| 732 | { | 965 | if (tmpp) |
| 733 | ERR_STATE_free(tmpp); | 966 | ERR_STATE_free(tmpp); |
| 734 | } | ||
| 735 | } | 967 | } |
| 736 | return(ret); | 968 | return ret; |
| 737 | } | 969 | } |
| 738 | 970 | ||
| 739 | int ERR_get_next_error_library(void) | 971 | int ERR_get_next_error_library(void) |
| 740 | { | 972 | { |
| 741 | static int value=ERR_LIB_USER; | 973 | err_fns_check(); |
| 742 | 974 | return ERRFN(get_next_lib)(); | |
| 743 | return(value++); | ||
| 744 | } | 975 | } |
| 745 | 976 | ||
| 746 | void ERR_set_error_data(char *data, int flags) | 977 | void ERR_set_error_data(char *data, int flags) |
| @@ -786,7 +1017,7 @@ void ERR_add_error_data(int num, ...) | |||
| 786 | if (p == NULL) | 1017 | if (p == NULL) |
| 787 | { | 1018 | { |
| 788 | OPENSSL_free(str); | 1019 | OPENSSL_free(str); |
| 789 | return; | 1020 | goto err; |
| 790 | } | 1021 | } |
| 791 | else | 1022 | else |
| 792 | str=p; | 1023 | str=p; |
| @@ -796,6 +1027,6 @@ void ERR_add_error_data(int num, ...) | |||
| 796 | } | 1027 | } |
| 797 | ERR_set_error_data(str,ERR_TXT_MALLOCED|ERR_TXT_STRING); | 1028 | ERR_set_error_data(str,ERR_TXT_MALLOCED|ERR_TXT_STRING); |
| 798 | 1029 | ||
| 1030 | err: | ||
| 799 | va_end(args); | 1031 | va_end(args); |
| 800 | } | 1032 | } |
| 801 | |||
diff --git a/src/lib/libcrypto/err/err.h b/src/lib/libcrypto/err/err.h index 7388a4a937..cc9bb649ea 100644 --- a/src/lib/libcrypto/err/err.h +++ b/src/lib/libcrypto/err/err.h | |||
| @@ -59,15 +59,15 @@ | |||
| 59 | #ifndef HEADER_ERR_H | 59 | #ifndef HEADER_ERR_H |
| 60 | #define HEADER_ERR_H | 60 | #define HEADER_ERR_H |
| 61 | 61 | ||
| 62 | #ifndef NO_FP_API | 62 | #ifndef OPENSSL_NO_FP_API |
| 63 | #include <stdio.h> | 63 | #include <stdio.h> |
| 64 | #include <stdlib.h> | 64 | #include <stdlib.h> |
| 65 | #endif | 65 | #endif |
| 66 | 66 | ||
| 67 | #ifndef NO_BIO | 67 | #ifndef OPENSSL_NO_BIO |
| 68 | #include <openssl/bio.h> | 68 | #include <openssl/bio.h> |
| 69 | #endif | 69 | #endif |
| 70 | #ifndef NO_LHASH | 70 | #ifndef OPENSSL_NO_LHASH |
| 71 | #include <openssl/lhash.h> | 71 | #include <openssl/lhash.h> |
| 72 | #endif | 72 | #endif |
| 73 | 73 | ||
| @@ -75,13 +75,7 @@ | |||
| 75 | extern "C" { | 75 | extern "C" { |
| 76 | #endif | 76 | #endif |
| 77 | 77 | ||
| 78 | /* The following is a bit of a trick to help the object files only contain | 78 | #ifndef OPENSSL_NO_ERR |
| 79 | * the 'name of the file' string once. Since 'err.h' is protected by the | ||
| 80 | * HEADER_ERR_H stuff, this should be included only once per file. */ | ||
| 81 | |||
| 82 | #define ERR_file_name __FILE__ | ||
| 83 | |||
| 84 | #ifndef NO_ERR | ||
| 85 | #define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,d,e) | 79 | #define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,d,e) |
| 86 | #else | 80 | #else |
| 87 | #define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,NULL,0) | 81 | #define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,NULL,0) |
| @@ -116,16 +110,17 @@ typedef struct err_state_st | |||
| 116 | #define ERR_LIB_PEM 9 | 110 | #define ERR_LIB_PEM 9 |
| 117 | #define ERR_LIB_DSA 10 | 111 | #define ERR_LIB_DSA 10 |
| 118 | #define ERR_LIB_X509 11 | 112 | #define ERR_LIB_X509 11 |
| 119 | #define ERR_LIB_METH 12 | 113 | /* #define ERR_LIB_METH 12 */ |
| 120 | #define ERR_LIB_ASN1 13 | 114 | #define ERR_LIB_ASN1 13 |
| 121 | #define ERR_LIB_CONF 14 | 115 | #define ERR_LIB_CONF 14 |
| 122 | #define ERR_LIB_CRYPTO 15 | 116 | #define ERR_LIB_CRYPTO 15 |
| 117 | #define ERR_LIB_EC 16 | ||
| 123 | #define ERR_LIB_SSL 20 | 118 | #define ERR_LIB_SSL 20 |
| 124 | #define ERR_LIB_SSL23 21 | 119 | /* #define ERR_LIB_SSL23 21 */ |
| 125 | #define ERR_LIB_SSL2 22 | 120 | /* #define ERR_LIB_SSL2 22 */ |
| 126 | #define ERR_LIB_SSL3 23 | 121 | /* #define ERR_LIB_SSL3 23 */ |
| 127 | #define ERR_LIB_RSAREF 30 | 122 | /* #define ERR_LIB_RSAREF 30 */ |
| 128 | #define ERR_LIB_PROXY 31 | 123 | /* #define ERR_LIB_PROXY 31 */ |
| 129 | #define ERR_LIB_BIO 32 | 124 | #define ERR_LIB_BIO 32 |
| 130 | #define ERR_LIB_PKCS7 33 | 125 | #define ERR_LIB_PKCS7 33 |
| 131 | #define ERR_LIB_X509V3 34 | 126 | #define ERR_LIB_X509V3 34 |
| @@ -133,36 +128,37 @@ typedef struct err_state_st | |||
| 133 | #define ERR_LIB_RAND 36 | 128 | #define ERR_LIB_RAND 36 |
| 134 | #define ERR_LIB_DSO 37 | 129 | #define ERR_LIB_DSO 37 |
| 135 | #define ERR_LIB_ENGINE 38 | 130 | #define ERR_LIB_ENGINE 38 |
| 131 | #define ERR_LIB_OCSP 39 | ||
| 132 | #define ERR_LIB_UI 40 | ||
| 133 | #define ERR_LIB_COMP 41 | ||
| 136 | 134 | ||
| 137 | #define ERR_LIB_USER 128 | 135 | #define ERR_LIB_USER 128 |
| 138 | 136 | ||
| 139 | #define SYSerr(f,r) ERR_PUT_error(ERR_LIB_SYS,(f),(r),ERR_file_name,__LINE__) | 137 | #define SYSerr(f,r) ERR_PUT_error(ERR_LIB_SYS,(f),(r),__FILE__,__LINE__) |
| 140 | #define BNerr(f,r) ERR_PUT_error(ERR_LIB_BN,(f),(r),ERR_file_name,__LINE__) | 138 | #define BNerr(f,r) ERR_PUT_error(ERR_LIB_BN,(f),(r),__FILE__,__LINE__) |
| 141 | #define RSAerr(f,r) ERR_PUT_error(ERR_LIB_RSA,(f),(r),ERR_file_name,__LINE__) | 139 | #define RSAerr(f,r) ERR_PUT_error(ERR_LIB_RSA,(f),(r),__FILE__,__LINE__) |
| 142 | #define DHerr(f,r) ERR_PUT_error(ERR_LIB_DH,(f),(r),ERR_file_name,__LINE__) | 140 | #define DHerr(f,r) ERR_PUT_error(ERR_LIB_DH,(f),(r),__FILE__,__LINE__) |
| 143 | #define EVPerr(f,r) ERR_PUT_error(ERR_LIB_EVP,(f),(r),ERR_file_name,__LINE__) | 141 | #define EVPerr(f,r) ERR_PUT_error(ERR_LIB_EVP,(f),(r),__FILE__,__LINE__) |
| 144 | #define BUFerr(f,r) ERR_PUT_error(ERR_LIB_BUF,(f),(r),ERR_file_name,__LINE__) | 142 | #define BUFerr(f,r) ERR_PUT_error(ERR_LIB_BUF,(f),(r),__FILE__,__LINE__) |
| 145 | #define BIOerr(f,r) ERR_PUT_error(ERR_LIB_BIO,(f),(r),ERR_file_name,__LINE__) | 143 | #define OBJerr(f,r) ERR_PUT_error(ERR_LIB_OBJ,(f),(r),__FILE__,__LINE__) |
| 146 | #define OBJerr(f,r) ERR_PUT_error(ERR_LIB_OBJ,(f),(r),ERR_file_name,__LINE__) | 144 | #define PEMerr(f,r) ERR_PUT_error(ERR_LIB_PEM,(f),(r),__FILE__,__LINE__) |
| 147 | #define PEMerr(f,r) ERR_PUT_error(ERR_LIB_PEM,(f),(r),ERR_file_name,__LINE__) | 145 | #define DSAerr(f,r) ERR_PUT_error(ERR_LIB_DSA,(f),(r),__FILE__,__LINE__) |
| 148 | #define DSAerr(f,r) ERR_PUT_error(ERR_LIB_DSA,(f),(r),ERR_file_name,__LINE__) | 146 | #define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),__FILE__,__LINE__) |
| 149 | #define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),ERR_file_name,__LINE__) | 147 | #define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),__FILE__,__LINE__) |
| 150 | #define METHerr(f,r) ERR_PUT_error(ERR_LIB_METH,(f),(r),ERR_file_name,__LINE__) | 148 | #define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),__FILE__,__LINE__) |
| 151 | #define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),ERR_file_name,__LINE__) | 149 | #define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),__FILE__,__LINE__) |
| 152 | #define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),ERR_file_name,__LINE__) | 150 | #define ECerr(f,r) ERR_PUT_error(ERR_LIB_EC,(f),(r),__FILE__,__LINE__) |
| 153 | #define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),ERR_file_name,__LINE__) | 151 | #define SSLerr(f,r) ERR_PUT_error(ERR_LIB_SSL,(f),(r),__FILE__,__LINE__) |
| 154 | #define SSLerr(f,r) ERR_PUT_error(ERR_LIB_SSL,(f),(r),ERR_file_name,__LINE__) | 152 | #define BIOerr(f,r) ERR_PUT_error(ERR_LIB_BIO,(f),(r),__FILE__,__LINE__) |
| 155 | #define SSL23err(f,r) ERR_PUT_error(ERR_LIB_SSL23,(f),(r),ERR_file_name,__LINE__) | 153 | #define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),__FILE__,__LINE__) |
| 156 | #define SSL2err(f,r) ERR_PUT_error(ERR_LIB_SSL2,(f),(r),ERR_file_name,__LINE__) | 154 | #define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),__FILE__,__LINE__) |
| 157 | #define SSL3err(f,r) ERR_PUT_error(ERR_LIB_SSL3,(f),(r),ERR_file_name,__LINE__) | 155 | #define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),__FILE__,__LINE__) |
| 158 | #define RSAREFerr(f,r) ERR_PUT_error(ERR_LIB_RSAREF,(f),(r),ERR_file_name,__LINE__) | 156 | #define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),__FILE__,__LINE__) |
| 159 | #define PROXYerr(f,r) ERR_PUT_error(ERR_LIB_PROXY,(f),(r),ERR_file_name,__LINE__) | 157 | #define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),__FILE__,__LINE__) |
| 160 | #define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),ERR_file_name,__LINE__) | 158 | #define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),__FILE__,__LINE__) |
| 161 | #define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),ERR_file_name,__LINE__) | 159 | #define OCSPerr(f,r) ERR_PUT_error(ERR_LIB_OCSP,(f),(r),__FILE__,__LINE__) |
| 162 | #define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),ERR_file_name,__LINE__) | 160 | #define UIerr(f,r) ERR_PUT_error(ERR_LIB_UI,(f),(r),__FILE__,__LINE__) |
| 163 | #define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),ERR_file_name,__LINE__) | 161 | #define COMPerr(f,r) ERR_PUT_error(ERR_LIB_COMP,(f),(r),__FILE__,__LINE__) |
| 164 | #define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),ERR_file_name,__LINE__) | ||
| 165 | #define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),ERR_file_name,__LINE__) | ||
| 166 | 162 | ||
| 167 | /* Borland C seems too stupid to be able to shift and do longs in | 163 | /* Borland C seems too stupid to be able to shift and do longs in |
| 168 | * the pre-processor :-( */ | 164 | * the pre-processor :-( */ |
| @@ -174,6 +170,7 @@ typedef struct err_state_st | |||
| 174 | #define ERR_GET_REASON(l) (int)((l)&0xfffL) | 170 | #define ERR_GET_REASON(l) (int)((l)&0xfffL) |
| 175 | #define ERR_FATAL_ERROR(l) (int)((l)&ERR_R_FATAL) | 171 | #define ERR_FATAL_ERROR(l) (int)((l)&ERR_R_FATAL) |
| 176 | 172 | ||
| 173 | |||
| 177 | /* OS functions */ | 174 | /* OS functions */ |
| 178 | #define SYS_F_FOPEN 1 | 175 | #define SYS_F_FOPEN 1 |
| 179 | #define SYS_F_CONNECT 2 | 176 | #define SYS_F_CONNECT 2 |
| @@ -186,44 +183,51 @@ typedef struct err_state_st | |||
| 186 | #define SYS_F_WSASTARTUP 9 /* Winsock stuff */ | 183 | #define SYS_F_WSASTARTUP 9 /* Winsock stuff */ |
| 187 | #define SYS_F_OPENDIR 10 | 184 | #define SYS_F_OPENDIR 10 |
| 188 | 185 | ||
| 189 | #define ERR_R_FATAL 32 | 186 | |
| 190 | /* reasons */ | 187 | /* reasons */ |
| 191 | #define ERR_R_SYS_LIB ERR_LIB_SYS | 188 | #define ERR_R_SYS_LIB ERR_LIB_SYS /* 2 */ |
| 192 | #define ERR_R_BN_LIB ERR_LIB_BN | 189 | #define ERR_R_BN_LIB ERR_LIB_BN /* 3 */ |
| 193 | #define ERR_R_RSA_LIB ERR_LIB_RSA | 190 | #define ERR_R_RSA_LIB ERR_LIB_RSA /* 4 */ |
| 194 | #define ERR_R_DSA_LIB ERR_LIB_DSA | 191 | #define ERR_R_DH_LIB ERR_LIB_DH /* 5 */ |
| 195 | #define ERR_R_DH_LIB ERR_LIB_DH | 192 | #define ERR_R_EVP_LIB ERR_LIB_EVP /* 6 */ |
| 196 | #define ERR_R_EVP_LIB ERR_LIB_EVP | 193 | #define ERR_R_BUF_LIB ERR_LIB_BUF /* 7 */ |
| 197 | #define ERR_R_BUF_LIB ERR_LIB_BUF | 194 | #define ERR_R_OBJ_LIB ERR_LIB_OBJ /* 8 */ |
| 198 | #define ERR_R_BIO_LIB ERR_LIB_BIO | 195 | #define ERR_R_PEM_LIB ERR_LIB_PEM /* 9 */ |
| 199 | #define ERR_R_OBJ_LIB ERR_LIB_OBJ | 196 | #define ERR_R_DSA_LIB ERR_LIB_DSA /* 10 */ |
| 200 | #define ERR_R_PEM_LIB ERR_LIB_PEM | 197 | #define ERR_R_X509_LIB ERR_LIB_X509 /* 11 */ |
| 201 | #define ERR_R_X509_LIB ERR_LIB_X509 | 198 | #define ERR_R_ASN1_LIB ERR_LIB_ASN1 /* 13 */ |
| 202 | #define ERR_R_METH_LIB ERR_LIB_METH | 199 | #define ERR_R_CONF_LIB ERR_LIB_CONF /* 14 */ |
| 203 | #define ERR_R_ASN1_LIB ERR_LIB_ASN1 | 200 | #define ERR_R_CRYPTO_LIB ERR_LIB_CRYPTO /* 15 */ |
| 204 | #define ERR_R_CONF_LIB ERR_LIB_CONF | 201 | #define ERR_R_EC_LIB ERR_LIB_EC /* 16 */ |
| 205 | #define ERR_R_CRYPTO_LIB ERR_LIB_CRYPTO | 202 | #define ERR_R_SSL_LIB ERR_LIB_SSL /* 20 */ |
| 206 | #define ERR_R_SSL_LIB ERR_LIB_SSL | 203 | #define ERR_R_BIO_LIB ERR_LIB_BIO /* 32 */ |
| 207 | #define ERR_R_SSL23_LIB ERR_LIB_SSL23 | 204 | #define ERR_R_PKCS7_LIB ERR_LIB_PKCS7 /* 33 */ |
| 208 | #define ERR_R_SSL2_LIB ERR_LIB_SSL2 | 205 | #define ERR_R_X509V3_LIB ERR_LIB_X509V3 /* 34 */ |
| 209 | #define ERR_R_SSL3_LIB ERR_LIB_SSL3 | 206 | #define ERR_R_PKCS12_LIB ERR_LIB_PKCS12 /* 35 */ |
| 210 | #define ERR_R_PROXY_LIB ERR_LIB_PROXY | 207 | #define ERR_R_RAND_LIB ERR_LIB_RAND /* 36 */ |
| 211 | #define ERR_R_BIO_LIB ERR_LIB_BIO | 208 | #define ERR_R_DSO_LIB ERR_LIB_DSO /* 37 */ |
| 212 | #define ERR_R_PKCS7_LIB ERR_LIB_PKCS7 | 209 | #define ERR_R_ENGINE_LIB ERR_LIB_ENGINE /* 38 */ |
| 213 | #define ERR_R_PKCS12_LIB ERR_LIB_PKCS12 | 210 | #define ERR_R_OCSP_LIB ERR_LIB_OCSP /* 39 */ |
| 214 | #define ERR_R_DSO_LIB ERR_LIB_DSO | 211 | #define ERR_R_UI_LIB ERR_LIB_UI /* 40 */ |
| 215 | #define ERR_R_ENGINE_LIB ERR_LIB_ENGINE | 212 | #define ERR_R_COMP_LIB ERR_LIB_COMP /* 41 */ |
| 213 | |||
| 214 | #define ERR_R_NESTED_ASN1_ERROR 58 | ||
| 215 | #define ERR_R_BAD_ASN1_OBJECT_HEADER 59 | ||
| 216 | #define ERR_R_BAD_GET_ASN1_OBJECT_CALL 60 | ||
| 217 | #define ERR_R_EXPECTING_AN_ASN1_SEQUENCE 61 | ||
| 218 | #define ERR_R_ASN1_LENGTH_MISMATCH 62 | ||
| 219 | #define ERR_R_MISSING_ASN1_EOS 63 | ||
| 216 | 220 | ||
| 217 | /* fatal error */ | 221 | /* fatal error */ |
| 222 | #define ERR_R_FATAL 64 | ||
| 218 | #define ERR_R_MALLOC_FAILURE (1|ERR_R_FATAL) | 223 | #define ERR_R_MALLOC_FAILURE (1|ERR_R_FATAL) |
| 219 | #define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED (2|ERR_R_FATAL) | 224 | #define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED (2|ERR_R_FATAL) |
| 220 | #define ERR_R_PASSED_NULL_PARAMETER (3|ERR_R_FATAL) | 225 | #define ERR_R_PASSED_NULL_PARAMETER (3|ERR_R_FATAL) |
| 221 | #define ERR_R_NESTED_ASN1_ERROR (4) | 226 | #define ERR_R_INTERNAL_ERROR (4|ERR_R_FATAL) |
| 222 | #define ERR_R_BAD_ASN1_OBJECT_HEADER (5) | 227 | |
| 223 | #define ERR_R_BAD_GET_ASN1_OBJECT_CALL (6) | 228 | /* 99 is the maximum possible ERR_R_... code, higher values |
| 224 | #define ERR_R_EXPECTING_AN_ASN1_SEQUENCE (7) | 229 | * are reserved for the individual libraries */ |
| 225 | #define ERR_R_ASN1_LENGTH_MISMATCH (8) | 230 | |
| 226 | #define ERR_R_MISSING_ASN1_EOS (9) | ||
| 227 | 231 | ||
| 228 | typedef struct ERR_string_data_st | 232 | typedef struct ERR_string_data_st |
| 229 | { | 233 | { |
| @@ -234,28 +238,35 @@ typedef struct ERR_string_data_st | |||
| 234 | void ERR_put_error(int lib, int func,int reason,const char *file,int line); | 238 | void ERR_put_error(int lib, int func,int reason,const char *file,int line); |
| 235 | void ERR_set_error_data(char *data,int flags); | 239 | void ERR_set_error_data(char *data,int flags); |
| 236 | 240 | ||
| 237 | unsigned long ERR_get_error(void ); | 241 | unsigned long ERR_get_error(void); |
| 238 | unsigned long ERR_get_error_line(const char **file,int *line); | 242 | unsigned long ERR_get_error_line(const char **file,int *line); |
| 239 | unsigned long ERR_get_error_line_data(const char **file,int *line, | 243 | unsigned long ERR_get_error_line_data(const char **file,int *line, |
| 240 | const char **data, int *flags); | 244 | const char **data, int *flags); |
| 241 | unsigned long ERR_peek_error(void ); | 245 | unsigned long ERR_peek_error(void); |
| 242 | unsigned long ERR_peek_error_line(const char **file,int *line); | 246 | unsigned long ERR_peek_error_line(const char **file,int *line); |
| 243 | unsigned long ERR_peek_error_line_data(const char **file,int *line, | 247 | unsigned long ERR_peek_error_line_data(const char **file,int *line, |
| 244 | const char **data,int *flags); | 248 | const char **data,int *flags); |
| 249 | unsigned long ERR_peek_last_error(void); | ||
| 250 | unsigned long ERR_peek_last_error_line(const char **file,int *line); | ||
| 251 | unsigned long ERR_peek_last_error_line_data(const char **file,int *line, | ||
| 252 | const char **data,int *flags); | ||
| 245 | void ERR_clear_error(void ); | 253 | void ERR_clear_error(void ); |
| 246 | char *ERR_error_string(unsigned long e,char *buf); | 254 | char *ERR_error_string(unsigned long e,char *buf); |
| 247 | void ERR_error_string_n(unsigned long e, char *buf, size_t len); | 255 | void ERR_error_string_n(unsigned long e, char *buf, size_t len); |
| 248 | const char *ERR_lib_error_string(unsigned long e); | 256 | const char *ERR_lib_error_string(unsigned long e); |
| 249 | const char *ERR_func_error_string(unsigned long e); | 257 | const char *ERR_func_error_string(unsigned long e); |
| 250 | const char *ERR_reason_error_string(unsigned long e); | 258 | const char *ERR_reason_error_string(unsigned long e); |
| 251 | #ifndef NO_FP_API | 259 | void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u), |
| 260 | void *u); | ||
| 261 | #ifndef OPENSSL_NO_FP_API | ||
| 252 | void ERR_print_errors_fp(FILE *fp); | 262 | void ERR_print_errors_fp(FILE *fp); |
| 253 | #endif | 263 | #endif |
| 254 | #ifndef NO_BIO | 264 | #ifndef OPENSSL_NO_BIO |
| 255 | void ERR_print_errors(BIO *bp); | 265 | void ERR_print_errors(BIO *bp); |
| 256 | void ERR_add_error_data(int num, ...); | 266 | void ERR_add_error_data(int num, ...); |
| 257 | #endif | 267 | #endif |
| 258 | void ERR_load_strings(int lib,ERR_STRING_DATA str[]); | 268 | void ERR_load_strings(int lib,ERR_STRING_DATA str[]); |
| 269 | void ERR_unload_strings(int lib,ERR_STRING_DATA str[]); | ||
| 259 | void ERR_load_ERR_strings(void); | 270 | void ERR_load_ERR_strings(void); |
| 260 | void ERR_load_crypto_strings(void); | 271 | void ERR_load_crypto_strings(void); |
| 261 | void ERR_free_strings(void); | 272 | void ERR_free_strings(void); |
| @@ -263,14 +274,22 @@ void ERR_free_strings(void); | |||
| 263 | void ERR_remove_state(unsigned long pid); /* if zero we look it up */ | 274 | void ERR_remove_state(unsigned long pid); /* if zero we look it up */ |
| 264 | ERR_STATE *ERR_get_state(void); | 275 | ERR_STATE *ERR_get_state(void); |
| 265 | 276 | ||
| 266 | #ifndef NO_LHASH | 277 | #ifndef OPENSSL_NO_LHASH |
| 267 | LHASH *ERR_get_string_table(void); | 278 | LHASH *ERR_get_string_table(void); |
| 268 | LHASH *ERR_get_err_state_table(void); /* even less thread-safe than | 279 | LHASH *ERR_get_err_state_table(void); |
| 269 | * ERR_get_string_table :-) */ | ||
| 270 | #endif | 280 | #endif |
| 271 | 281 | ||
| 272 | int ERR_get_next_error_library(void); | 282 | int ERR_get_next_error_library(void); |
| 273 | 283 | ||
| 284 | /* This opaque type encapsulates the low-level error-state functions */ | ||
| 285 | typedef struct st_ERR_FNS ERR_FNS; | ||
| 286 | /* An application can use this function and provide the return value to loaded | ||
| 287 | * modules that should use the application's ERR state/functionality */ | ||
| 288 | const ERR_FNS *ERR_get_implementation(void); | ||
| 289 | /* A loaded module should call this function prior to any ERR operations using | ||
| 290 | * the application's "ERR_FNS". */ | ||
| 291 | int ERR_set_implementation(const ERR_FNS *fns); | ||
| 292 | |||
| 274 | #ifdef __cplusplus | 293 | #ifdef __cplusplus |
| 275 | } | 294 | } |
| 276 | #endif | 295 | #endif |
diff --git a/src/lib/libcrypto/err/err_all.c b/src/lib/libcrypto/err/err_all.c index b8315d8272..90029fd159 100644 --- a/src/lib/libcrypto/err/err_all.c +++ b/src/lib/libcrypto/err/err_all.c | |||
| @@ -59,18 +59,18 @@ | |||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include <openssl/asn1.h> | 60 | #include <openssl/asn1.h> |
| 61 | #include <openssl/bn.h> | 61 | #include <openssl/bn.h> |
| 62 | #ifndef OPENSSL_NO_EC | ||
| 63 | #include <openssl/ec.h> | ||
| 64 | #endif | ||
| 62 | #include <openssl/buffer.h> | 65 | #include <openssl/buffer.h> |
| 63 | #include <openssl/bio.h> | 66 | #include <openssl/bio.h> |
| 64 | #ifndef NO_RSA | 67 | #ifndef OPENSSL_NO_RSA |
| 65 | #include <openssl/rsa.h> | 68 | #include <openssl/rsa.h> |
| 66 | #endif | 69 | #endif |
| 67 | #ifdef RSAref | 70 | #ifndef OPENSSL_NO_DH |
| 68 | #include <openssl/rsaref.h> | ||
| 69 | #endif | ||
| 70 | #ifndef NO_DH | ||
| 71 | #include <openssl/dh.h> | 71 | #include <openssl/dh.h> |
| 72 | #endif | 72 | #endif |
| 73 | #ifndef NO_DSA | 73 | #ifndef OPENSSL_NO_DSA |
| 74 | #include <openssl/dsa.h> | 74 | #include <openssl/dsa.h> |
| 75 | #endif | 75 | #endif |
| 76 | #include <openssl/evp.h> | 76 | #include <openssl/evp.h> |
| @@ -83,6 +83,7 @@ | |||
| 83 | #include <openssl/rand.h> | 83 | #include <openssl/rand.h> |
| 84 | #include <openssl/dso.h> | 84 | #include <openssl/dso.h> |
| 85 | #include <openssl/engine.h> | 85 | #include <openssl/engine.h> |
| 86 | #include <openssl/ocsp.h> | ||
| 86 | #include <openssl/err.h> | 87 | #include <openssl/err.h> |
| 87 | 88 | ||
| 88 | void ERR_load_crypto_strings(void) | 89 | void ERR_load_crypto_strings(void) |
| @@ -91,36 +92,38 @@ void ERR_load_crypto_strings(void) | |||
| 91 | 92 | ||
| 92 | if (done) return; | 93 | if (done) return; |
| 93 | done=1; | 94 | done=1; |
| 94 | #ifndef NO_ERR | 95 | #ifndef OPENSSL_NO_ERR |
| 95 | ERR_load_ASN1_strings(); | 96 | ERR_load_ERR_strings(); /* include error strings for SYSerr */ |
| 96 | ERR_load_BN_strings(); | 97 | ERR_load_BN_strings(); |
| 97 | ERR_load_BUF_strings(); | 98 | #ifndef OPENSSL_NO_RSA |
| 98 | ERR_load_BIO_strings(); | ||
| 99 | ERR_load_CONF_strings(); | ||
| 100 | #ifndef NO_RSA | ||
| 101 | #ifdef RSAref | ||
| 102 | ERR_load_RSAREF_strings(); | ||
| 103 | #else | ||
| 104 | ERR_load_RSA_strings(); | 99 | ERR_load_RSA_strings(); |
| 105 | #endif | 100 | #endif |
| 106 | #endif | 101 | #ifndef OPENSSL_NO_DH |
| 107 | #ifndef NO_DH | ||
| 108 | ERR_load_DH_strings(); | 102 | ERR_load_DH_strings(); |
| 109 | #endif | 103 | #endif |
| 110 | #ifndef NO_DSA | ||
| 111 | ERR_load_DSA_strings(); | ||
| 112 | #endif | ||
| 113 | ERR_load_ERR_strings(); | ||
| 114 | ERR_load_EVP_strings(); | 104 | ERR_load_EVP_strings(); |
| 105 | ERR_load_BUF_strings(); | ||
| 115 | ERR_load_OBJ_strings(); | 106 | ERR_load_OBJ_strings(); |
| 116 | ERR_load_PEM_strings(); | 107 | ERR_load_PEM_strings(); |
| 108 | #ifndef OPENSSL_NO_DSA | ||
| 109 | ERR_load_DSA_strings(); | ||
| 110 | #endif | ||
| 117 | ERR_load_X509_strings(); | 111 | ERR_load_X509_strings(); |
| 118 | ERR_load_X509V3_strings(); | 112 | ERR_load_ASN1_strings(); |
| 113 | ERR_load_CONF_strings(); | ||
| 119 | ERR_load_CRYPTO_strings(); | 114 | ERR_load_CRYPTO_strings(); |
| 120 | ERR_load_PKCS7_strings(); | 115 | #ifndef OPENSSL_NO_EC |
| 116 | ERR_load_EC_strings(); | ||
| 117 | #endif | ||
| 118 | /* skip ERR_load_SSL_strings() because it is not in this library */ | ||
| 119 | ERR_load_BIO_strings(); | ||
| 120 | ERR_load_PKCS7_strings(); | ||
| 121 | ERR_load_X509V3_strings(); | ||
| 121 | ERR_load_PKCS12_strings(); | 122 | ERR_load_PKCS12_strings(); |
| 122 | ERR_load_RAND_strings(); | 123 | ERR_load_RAND_strings(); |
| 123 | ERR_load_DSO_strings(); | 124 | ERR_load_DSO_strings(); |
| 124 | ERR_load_ENGINE_strings(); | 125 | ERR_load_ENGINE_strings(); |
| 126 | ERR_load_OCSP_strings(); | ||
| 127 | ERR_load_UI_strings(); | ||
| 125 | #endif | 128 | #endif |
| 126 | } | 129 | } |
diff --git a/src/lib/libcrypto/err/err_prn.c b/src/lib/libcrypto/err/err_prn.c index 6f60b016c3..c156663f0e 100644 --- a/src/lib/libcrypto/err/err_prn.c +++ b/src/lib/libcrypto/err/err_prn.c | |||
| @@ -64,11 +64,12 @@ | |||
| 64 | #include <openssl/err.h> | 64 | #include <openssl/err.h> |
| 65 | #include <openssl/crypto.h> | 65 | #include <openssl/crypto.h> |
| 66 | 66 | ||
| 67 | #ifndef NO_FP_API | 67 | void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u), |
| 68 | void ERR_print_errors_fp(FILE *fp) | 68 | void *u) |
| 69 | { | 69 | { |
| 70 | unsigned long l; | 70 | unsigned long l; |
| 71 | char buf[200]; | 71 | char buf[256]; |
| 72 | char buf2[4096]; | ||
| 72 | const char *file,*data; | 73 | const char *file,*data; |
| 73 | int line,flags; | 74 | int line,flags; |
| 74 | unsigned long es; | 75 | unsigned long es; |
| @@ -77,31 +78,30 @@ void ERR_print_errors_fp(FILE *fp) | |||
| 77 | while ((l=ERR_get_error_line_data(&file,&line,&data,&flags)) != 0) | 78 | while ((l=ERR_get_error_line_data(&file,&line,&data,&flags)) != 0) |
| 78 | { | 79 | { |
| 79 | ERR_error_string_n(l, buf, sizeof buf); | 80 | ERR_error_string_n(l, buf, sizeof buf); |
| 80 | fprintf(fp,"%lu:%s:%s:%d:%s\n",es,buf, | 81 | BIO_snprintf(buf2, sizeof(buf2), "%lu:%s:%s:%d:%s\n", es, buf, |
| 81 | file,line,(flags&ERR_TXT_STRING)?data:""); | 82 | file, line, (flags & ERR_TXT_STRING) ? data : ""); |
| 83 | cb(buf2, strlen(buf2), u); | ||
| 82 | } | 84 | } |
| 83 | } | 85 | } |
| 86 | |||
| 87 | #ifndef OPENSSL_NO_FP_API | ||
| 88 | static int print_fp(const char *str, size_t len, void *fp) | ||
| 89 | { | ||
| 90 | return fprintf((FILE *)fp, "%s", str); | ||
| 91 | } | ||
| 92 | void ERR_print_errors_fp(FILE *fp) | ||
| 93 | { | ||
| 94 | ERR_print_errors_cb(print_fp, fp); | ||
| 95 | } | ||
| 84 | #endif | 96 | #endif |
| 85 | 97 | ||
| 98 | static int print_bio(const char *str, size_t len, void *bp) | ||
| 99 | { | ||
| 100 | return BIO_write((BIO *)bp, str, len); | ||
| 101 | } | ||
| 86 | void ERR_print_errors(BIO *bp) | 102 | void ERR_print_errors(BIO *bp) |
| 87 | { | 103 | { |
| 88 | unsigned long l; | 104 | ERR_print_errors_cb(print_bio, bp); |
| 89 | char buf[256]; | ||
| 90 | char buf2[256]; | ||
| 91 | const char *file,*data; | ||
| 92 | int line,flags; | ||
| 93 | unsigned long es; | ||
| 94 | |||
| 95 | es=CRYPTO_thread_id(); | ||
| 96 | while ((l=ERR_get_error_line_data(&file,&line,&data,&flags)) != 0) | ||
| 97 | { | ||
| 98 | ERR_error_string_n(l, buf, sizeof buf); | ||
| 99 | sprintf(buf2,"%lu:%s:%s:%d:",es,buf, | ||
| 100 | file,line); | ||
| 101 | BIO_write(bp,buf2,strlen(buf2)); | ||
| 102 | if (flags & ERR_TXT_STRING) | ||
| 103 | BIO_write(bp,data,strlen(data)); | ||
| 104 | BIO_write(bp,"\n",1); | ||
| 105 | } | ||
| 106 | } | 105 | } |
| 107 | 106 | ||
| 107 | |||
diff --git a/src/lib/libcrypto/err/openssl.ec b/src/lib/libcrypto/err/openssl.ec index 861d680e07..29a69dfdd4 100644 --- a/src/lib/libcrypto/err/openssl.ec +++ b/src/lib/libcrypto/err/openssl.ec | |||
| @@ -1,29 +1,36 @@ | |||
| 1 | # crypto/err/openssl.ec | ||
| 2 | |||
| 3 | # configuration file for util/mkerr.pl | ||
| 4 | |||
| 5 | # files that may have to be rewritten by util/mkerr.pl | ||
| 1 | L ERR NONE NONE | 6 | L ERR NONE NONE |
| 2 | L CRYPTO crypto/crypto.h crypto/cpt_err.c | ||
| 3 | L BN crypto/bn/bn.h crypto/bn/bn_err.c | 7 | L BN crypto/bn/bn.h crypto/bn/bn_err.c |
| 4 | L RSA crypto/rsa/rsa.h crypto/rsa/rsa_err.c | 8 | L RSA crypto/rsa/rsa.h crypto/rsa/rsa_err.c |
| 5 | L DSA crypto/dsa/dsa.h crypto/dsa/dsa_err.c | ||
| 6 | L DSO crypto/dso/dso.h crypto/dso/dso_err.c | ||
| 7 | L DH crypto/dh/dh.h crypto/dh/dh_err.c | 9 | L DH crypto/dh/dh.h crypto/dh/dh_err.c |
| 8 | L EVP crypto/evp/evp.h crypto/evp/evp_err.c | 10 | L EVP crypto/evp/evp.h crypto/evp/evp_err.c |
| 9 | L BUF crypto/buffer/buffer.h crypto/buffer/buf_err.c | 11 | L BUF crypto/buffer/buffer.h crypto/buffer/buf_err.c |
| 10 | L BIO crypto/bio/bio.h crypto/bio/bio_err.c | ||
| 11 | L OBJ crypto/objects/objects.h crypto/objects/obj_err.c | 12 | L OBJ crypto/objects/objects.h crypto/objects/obj_err.c |
| 12 | L PEM crypto/pem/pem.h crypto/pem/pem_err.c | 13 | L PEM crypto/pem/pem.h crypto/pem/pem_err.c |
| 14 | L DSA crypto/dsa/dsa.h crypto/dsa/dsa_err.c | ||
| 13 | L X509 crypto/x509/x509.h crypto/x509/x509_err.c | 15 | L X509 crypto/x509/x509.h crypto/x509/x509_err.c |
| 14 | L NONE crypto/x509/x509_vfy.h NONE | ||
| 15 | L X509V3 crypto/x509v3/x509v3.h crypto/x509v3/v3err.c | ||
| 16 | #L METH crypto/meth/meth.h crypto/meth/meth_err.c | ||
| 17 | L ASN1 crypto/asn1/asn1.h crypto/asn1/asn1_err.c | 16 | L ASN1 crypto/asn1/asn1.h crypto/asn1/asn1_err.c |
| 18 | L CONF crypto/conf/conf.h crypto/conf/conf_err.c | 17 | L CONF crypto/conf/conf.h crypto/conf/conf_err.c |
| 19 | #L PROXY crypto/proxy/proxy.h crypto/proxy/proxy_err.c | 18 | L CRYPTO crypto/crypto.h crypto/cpt_err.c |
| 19 | L EC crypto/ec/ec.h crypto/ec/ec_err.c | ||
| 20 | L SSL ssl/ssl.h ssl/ssl_err.c | ||
| 21 | L BIO crypto/bio/bio.h crypto/bio/bio_err.c | ||
| 20 | L PKCS7 crypto/pkcs7/pkcs7.h crypto/pkcs7/pkcs7err.c | 22 | L PKCS7 crypto/pkcs7/pkcs7.h crypto/pkcs7/pkcs7err.c |
| 23 | L X509V3 crypto/x509v3/x509v3.h crypto/x509v3/v3err.c | ||
| 21 | L PKCS12 crypto/pkcs12/pkcs12.h crypto/pkcs12/pk12err.c | 24 | L PKCS12 crypto/pkcs12/pkcs12.h crypto/pkcs12/pk12err.c |
| 22 | L RSAREF rsaref/rsaref.h rsaref/rsar_err.c | ||
| 23 | L SSL ssl/ssl.h ssl/ssl_err.c | ||
| 24 | L COMP crypto/comp/comp.h crypto/comp/comp_err.c | ||
| 25 | L RAND crypto/rand/rand.h crypto/rand/rand_err.c | 25 | L RAND crypto/rand/rand.h crypto/rand/rand_err.c |
| 26 | L ENGINE crypto/engine/engine.h crypto/engine/engine_err.c | 26 | L DSO crypto/dso/dso.h crypto/dso/dso_err.c |
| 27 | L ENGINE crypto/engine/engine.h crypto/engine/eng_err.c | ||
| 28 | L OCSP crypto/ocsp/ocsp.h crypto/ocsp/ocsp_err.c | ||
| 29 | L UI crypto/ui/ui.h crypto/ui/ui_err.c | ||
| 30 | |||
| 31 | # additional header files to be scanned for function names | ||
| 32 | L NONE crypto/x509/x509_vfy.h NONE | ||
| 33 | L NONE crypto/ec/ec_lcl.h NONE | ||
| 27 | 34 | ||
| 28 | 35 | ||
| 29 | F RSAREF_F_RSA_BN2BIN | 36 | F RSAREF_F_RSA_BN2BIN |
