Latest update.
This commit is contained in:
+119
-1
@@ -17,12 +17,13 @@
|
||||
#include <openssl/err.h>
|
||||
#include "err_local.h"
|
||||
|
||||
#define ERR_PRINT_BUF_SIZE 4096
|
||||
void ERR_print_errors_cb(int (*cb) (const char *str, size_t len, void *u),
|
||||
void *u)
|
||||
{
|
||||
CRYPTO_THREAD_ID tid = CRYPTO_THREAD_get_current_id();
|
||||
unsigned long l;
|
||||
char buf[4096], *hex;
|
||||
char buf[ERR_PRINT_BUF_SIZE], *hex;
|
||||
const char *lib, *reason;
|
||||
const char *file, *data, *func;
|
||||
int line, flags;
|
||||
@@ -44,6 +45,123 @@ void ERR_print_errors_cb(int (*cb) (const char *str, size_t len, void *u),
|
||||
}
|
||||
}
|
||||
|
||||
/* auxiliary function for incrementally reporting texts via the error queue */
|
||||
static void put_error(int lib, const char *func, int reason,
|
||||
const char *file, int line)
|
||||
{
|
||||
ERR_new();
|
||||
ERR_set_debug(file, line, func);
|
||||
ERR_set_error(lib, reason, NULL /* no data here, so fmt is NULL */);
|
||||
}
|
||||
|
||||
#define TYPICAL_MAX_OUTPUT_BEFORE_DATA 100
|
||||
#define MAX_DATA_LEN (ERR_PRINT_BUF_SIZE - TYPICAL_MAX_OUTPUT_BEFORE_DATA)
|
||||
void ERR_add_error_txt(const char *separator, const char *txt)
|
||||
{
|
||||
const char *file = NULL;
|
||||
int line;
|
||||
const char *func = NULL;
|
||||
const char *data = NULL;
|
||||
int flags;
|
||||
unsigned long err = ERR_peek_last_error();
|
||||
|
||||
if (separator == NULL)
|
||||
separator = "";
|
||||
if (err == 0)
|
||||
put_error(ERR_LIB_CMP, NULL, 0, "", 0);
|
||||
|
||||
do {
|
||||
size_t available_len, data_len;
|
||||
const char *curr = txt, *next = txt;
|
||||
const char *leading_separator = separator;
|
||||
int trailing_separator = 0;
|
||||
char *tmp;
|
||||
|
||||
ERR_peek_last_error_all(&file, &line, &func, &data, &flags);
|
||||
if ((flags & ERR_TXT_STRING) == 0) {
|
||||
data = "";
|
||||
leading_separator = "";
|
||||
}
|
||||
data_len = strlen(data);
|
||||
|
||||
/* workaround for limit of ERR_print_errors_cb() */
|
||||
if (data_len >= MAX_DATA_LEN
|
||||
|| strlen(separator) >= (size_t)(MAX_DATA_LEN - data_len))
|
||||
available_len = 0;
|
||||
else
|
||||
available_len = MAX_DATA_LEN - data_len - strlen(separator) - 1;
|
||||
/* MAX_DATA_LEN > available_len >= 0 */
|
||||
|
||||
if (*separator == '\0') {
|
||||
const size_t len_next = strlen(next);
|
||||
|
||||
if (len_next <= available_len) {
|
||||
next += len_next;
|
||||
curr = NULL; /* no need to split */
|
||||
} else {
|
||||
next += available_len;
|
||||
curr = next; /* will split at this point */
|
||||
}
|
||||
} else {
|
||||
while (*next != '\0' && (size_t)(next - txt) <= available_len) {
|
||||
curr = next;
|
||||
next = strstr(curr, separator);
|
||||
if (next != NULL) {
|
||||
next += strlen(separator);
|
||||
trailing_separator = *next == '\0';
|
||||
} else {
|
||||
next = curr + strlen(curr);
|
||||
}
|
||||
}
|
||||
if ((size_t)(next - txt) <= available_len)
|
||||
curr = NULL; /* the above loop implies *next == '\0' */
|
||||
}
|
||||
if (curr != NULL) {
|
||||
/* split error msg at curr since error data would get too long */
|
||||
if (curr != txt) {
|
||||
tmp = OPENSSL_strndup(txt, curr - txt);
|
||||
if (tmp == NULL)
|
||||
return;
|
||||
ERR_add_error_data(2, separator, tmp);
|
||||
OPENSSL_free(tmp);
|
||||
}
|
||||
put_error(ERR_LIB_CMP, func, err, file, line);
|
||||
txt = curr;
|
||||
} else {
|
||||
if (trailing_separator) {
|
||||
tmp = OPENSSL_strndup(txt, next - strlen(separator) - txt);
|
||||
if (tmp == NULL)
|
||||
return;
|
||||
/* output txt without the trailing separator */
|
||||
ERR_add_error_data(2, leading_separator, tmp);
|
||||
OPENSSL_free(tmp);
|
||||
} else {
|
||||
ERR_add_error_data(2, leading_separator, txt);
|
||||
}
|
||||
txt = next; /* finished */
|
||||
}
|
||||
} while (*txt != '\0');
|
||||
}
|
||||
|
||||
void ERR_add_error_mem_bio(const char *separator, BIO *bio)
|
||||
{
|
||||
if (bio != NULL) {
|
||||
char *str;
|
||||
long len = BIO_get_mem_data(bio, &str);
|
||||
|
||||
if (len > 0) {
|
||||
if (str[len - 1] != '\0') {
|
||||
if (BIO_write(bio, "", 1) <= 0)
|
||||
return;
|
||||
|
||||
len = BIO_get_mem_data(bio, &str);
|
||||
}
|
||||
if (len > 1)
|
||||
ERR_add_error_txt(separator, str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int print_bio(const char *str, size_t len, void *bp)
|
||||
{
|
||||
return BIO_write((BIO *)bp, str, len);
|
||||
|
||||
+21
-1
@@ -2067,6 +2067,7 @@ BN_R_PRIVATE_KEY_TOO_LARGE:117:private key too large
|
||||
BN_R_P_IS_NOT_PRIME:112:p is not prime
|
||||
BN_R_TOO_MANY_ITERATIONS:113:too many iterations
|
||||
BN_R_TOO_MANY_TEMPORARY_VARIABLES:109:too many temporary variables
|
||||
CMP_R_ALGORITHM_NOT_SUPPORTED:139:algorithm not supported
|
||||
CMP_R_BAD_REQUEST_ID:108:bad request id
|
||||
CMP_R_CERTID_NOT_FOUND:109:certid not found
|
||||
CMP_R_CERTIFICATE_NOT_FOUND:112:certificate not found
|
||||
@@ -2087,24 +2088,41 @@ CMP_R_ERROR_CREATING_RR:126:error creating rr
|
||||
CMP_R_ERROR_PARSING_PKISTATUS:107:error parsing pkistatus
|
||||
CMP_R_ERROR_PROTECTING_MESSAGE:127:error protecting message
|
||||
CMP_R_ERROR_SETTING_CERTHASH:128:error setting certhash
|
||||
CMP_R_ERROR_VALIDATING_PROTECTION:140:error validating protection
|
||||
CMP_R_FAILED_EXTRACTING_PUBKEY:141:failed extracting pubkey
|
||||
CMP_R_FAILURE_OBTAINING_RANDOM:110:failure obtaining random
|
||||
CMP_R_FAIL_INFO_OUT_OF_RANGE:129:fail info out of range
|
||||
CMP_R_INVALID_ARGS:100:invalid args
|
||||
CMP_R_MISSING_KEY_INPUT_FOR_CREATING_PROTECTION:130:\
|
||||
missing key input for creating protection
|
||||
CMP_R_MISSING_KEY_USAGE_DIGITALSIGNATURE:142:missing key usage digitalsignature
|
||||
CMP_R_MISSING_PRIVATE_KEY:131:missing private key
|
||||
CMP_R_MISSING_PROTECTION:143:missing protection
|
||||
CMP_R_MISSING_SENDER_IDENTIFICATION:111:missing sender identification
|
||||
CMP_R_MISSING_TRUST_STORE:144:missing trust store
|
||||
CMP_R_MULTIPLE_SAN_SOURCES:102:multiple san sources
|
||||
CMP_R_NO_STDIO:194:no stdio
|
||||
CMP_R_NO_SUITABLE_SENDER_CERT:145:no suitable sender cert
|
||||
CMP_R_NULL_ARGUMENT:103:null argument
|
||||
CMP_R_PKIBODY_ERROR:146:pkibody error
|
||||
CMP_R_PKISTATUSINFO_NOT_FOUND:132:pkistatusinfo not found
|
||||
CMP_R_POTENTIALLY_INVALID_CERTIFICATE:139:potentially invalid certificate
|
||||
CMP_R_POTENTIALLY_INVALID_CERTIFICATE:147:potentially invalid certificate
|
||||
CMP_R_RECIPNONCE_UNMATCHED:148:recipnonce unmatched
|
||||
CMP_R_REQUEST_NOT_ACCEPTED:149:request not accepted
|
||||
CMP_R_SENDER_GENERALNAME_TYPE_NOT_SUPPORTED:150:\
|
||||
sender generalname type not supported
|
||||
CMP_R_SRVCERT_DOES_NOT_VALIDATE_MSG:151:srvcert does not validate msg
|
||||
CMP_R_TRANSACTIONID_UNMATCHED:152:transactionid unmatched
|
||||
CMP_R_UNEXPECTED_PKIBODY:133:unexpected pkibody
|
||||
CMP_R_UNEXPECTED_PVNO:153:unexpected pvno
|
||||
CMP_R_UNKNOWN_ALGORITHM_ID:134:unknown algorithm id
|
||||
CMP_R_UNKNOWN_CERT_TYPE:135:unknown cert type
|
||||
CMP_R_UNSUPPORTED_ALGORITHM:136:unsupported algorithm
|
||||
CMP_R_UNSUPPORTED_KEY_TYPE:137:unsupported key type
|
||||
CMP_R_UNSUPPORTED_PROTECTION_ALG_DHBASEDMAC:154:\
|
||||
unsupported protection alg dhbasedmac
|
||||
CMP_R_WRONG_ALGORITHM_OID:138:wrong algorithm oid
|
||||
CMP_R_WRONG_PBM_VALUE:155:wrong pbm value
|
||||
CMS_R_ADD_SIGNER_ERROR:99:add signer error
|
||||
CMS_R_ATTRIBUTE_ERROR:161:attribute error
|
||||
CMS_R_CERTIFICATE_ALREADY_PRESENT:175:certificate already present
|
||||
@@ -2741,6 +2759,7 @@ PROV_R_BAD_TLS_CLIENT_VERSION:161:bad tls client version
|
||||
PROV_R_BN_ERROR:160:bn error
|
||||
PROV_R_BOTH_MODE_AND_MODE_INT:127:both mode and mode int
|
||||
PROV_R_CIPHER_OPERATION_FAILED:102:cipher operation failed
|
||||
PROV_R_FAILED_DURING_DERIVATION:164:failed during derivation
|
||||
PROV_R_FAILED_TO_DECRYPT:162:failed to decrypt
|
||||
PROV_R_FAILED_TO_GENERATE_KEY:121:failed to generate key
|
||||
PROV_R_FAILED_TO_GET_PARAMETER:103:failed to get parameter
|
||||
@@ -3362,6 +3381,7 @@ X509_R_BAD_SELECTOR:133:bad selector
|
||||
X509_R_BAD_X509_FILETYPE:100:bad x509 filetype
|
||||
X509_R_BASE64_DECODE_ERROR:118:base64 decode error
|
||||
X509_R_CANT_CHECK_DH_KEY:114:cant check dh key
|
||||
X509_R_CERTIFICATE_VERIFICATION_FAILED:139:certificate verification failed
|
||||
X509_R_CERT_ALREADY_IN_HASH_TABLE:101:cert already in hash table
|
||||
X509_R_CRL_ALREADY_DELTA:127:crl already delta
|
||||
X509_R_CRL_VERIFY_FAILURE:131:crl verify failure
|
||||
|
||||
@@ -1822,13 +1822,13 @@ X509V3_F_X509_PURPOSE_SET:141:X509_PURPOSE_set
|
||||
X509_F_ADD_CERT_DIR:100:add_cert_dir
|
||||
X509_F_BUILD_CHAIN:106:build_chain
|
||||
X509_F_BY_FILE_CTRL:101:by_file_ctrl
|
||||
X509_F_CACHE_OBJECTS:163:cache_objects
|
||||
X509_F_CHECK_NAME_CONSTRAINTS:149:check_name_constraints
|
||||
X509_F_CHECK_POLICY:145:check_policy
|
||||
X509_F_COMMON_VERIFY_SM2:165:common_verify_sm2
|
||||
X509_F_DANE_I2D:107:dane_i2d
|
||||
X509_F_DIR_CTRL:102:dir_ctrl
|
||||
X509_F_GET_CERT_BY_SUBJECT:103:get_cert_by_subject
|
||||
X509_F_CACHE_OBJECTS:163:cache_objects
|
||||
X509_F_I2D_X509_AUX:151:i2d_X509_AUX
|
||||
X509_F_LOOKUP_CERTS_SK:152:lookup_certs_sk
|
||||
X509_F_NETSCAPE_SPKI_B64_DECODE:129:NETSCAPE_SPKI_b64_decode
|
||||
@@ -2067,6 +2067,7 @@ BN_R_PRIVATE_KEY_TOO_LARGE:117:private key too large
|
||||
BN_R_P_IS_NOT_PRIME:112:p is not prime
|
||||
BN_R_TOO_MANY_ITERATIONS:113:too many iterations
|
||||
BN_R_TOO_MANY_TEMPORARY_VARIABLES:109:too many temporary variables
|
||||
CMP_R_ALGORITHM_NOT_SUPPORTED:139:algorithm not supported
|
||||
CMP_R_BAD_REQUEST_ID:108:bad request id
|
||||
CMP_R_CERTID_NOT_FOUND:109:certid not found
|
||||
CMP_R_CERTIFICATE_NOT_FOUND:112:certificate not found
|
||||
@@ -2087,24 +2088,41 @@ CMP_R_ERROR_CREATING_RR:126:error creating rr
|
||||
CMP_R_ERROR_PARSING_PKISTATUS:107:error parsing pkistatus
|
||||
CMP_R_ERROR_PROTECTING_MESSAGE:127:error protecting message
|
||||
CMP_R_ERROR_SETTING_CERTHASH:128:error setting certhash
|
||||
CMP_R_ERROR_VALIDATING_PROTECTION:140:error validating protection
|
||||
CMP_R_FAILED_EXTRACTING_PUBKEY:141:failed extracting pubkey
|
||||
CMP_R_FAILURE_OBTAINING_RANDOM:110:failure obtaining random
|
||||
CMP_R_FAIL_INFO_OUT_OF_RANGE:129:fail info out of range
|
||||
CMP_R_INVALID_ARGS:100:invalid args
|
||||
CMP_R_MISSING_KEY_INPUT_FOR_CREATING_PROTECTION:130:\
|
||||
missing key input for creating protection
|
||||
CMP_R_MISSING_KEY_USAGE_DIGITALSIGNATURE:142:missing key usage digitalsignature
|
||||
CMP_R_MISSING_PRIVATE_KEY:131:missing private key
|
||||
CMP_R_MISSING_PROTECTION:143:missing protection
|
||||
CMP_R_MISSING_SENDER_IDENTIFICATION:111:missing sender identification
|
||||
CMP_R_MISSING_TRUST_STORE:144:missing trust store
|
||||
CMP_R_MULTIPLE_SAN_SOURCES:102:multiple san sources
|
||||
CMP_R_NO_STDIO:194:no stdio
|
||||
CMP_R_NO_SUITABLE_SENDER_CERT:145:no suitable sender cert
|
||||
CMP_R_NULL_ARGUMENT:103:null argument
|
||||
CMP_R_PKIBODY_ERROR:146:pkibody error
|
||||
CMP_R_PKISTATUSINFO_NOT_FOUND:132:pkistatusinfo not found
|
||||
CMP_R_POTENTIALLY_INVALID_CERTIFICATE:139:potentially invalid certificate
|
||||
CMP_R_POTENTIALLY_INVALID_CERTIFICATE:147:potentially invalid certificate
|
||||
CMP_R_RECIPNONCE_UNMATCHED:148:recipnonce unmatched
|
||||
CMP_R_REQUEST_NOT_ACCEPTED:149:request not accepted
|
||||
CMP_R_SENDER_GENERALNAME_TYPE_NOT_SUPPORTED:150:\
|
||||
sender generalname type not supported
|
||||
CMP_R_SRVCERT_DOES_NOT_VALIDATE_MSG:151:srvcert does not validate msg
|
||||
CMP_R_TRANSACTIONID_UNMATCHED:152:transactionid unmatched
|
||||
CMP_R_UNEXPECTED_PKIBODY:133:unexpected pkibody
|
||||
CMP_R_UNEXPECTED_PVNO:153:unexpected pvno
|
||||
CMP_R_UNKNOWN_ALGORITHM_ID:134:unknown algorithm id
|
||||
CMP_R_UNKNOWN_CERT_TYPE:135:unknown cert type
|
||||
CMP_R_UNSUPPORTED_ALGORITHM:136:unsupported algorithm
|
||||
CMP_R_UNSUPPORTED_KEY_TYPE:137:unsupported key type
|
||||
CMP_R_UNSUPPORTED_PROTECTION_ALG_DHBASEDMAC:154:\
|
||||
unsupported protection alg dhbasedmac
|
||||
CMP_R_WRONG_ALGORITHM_OID:138:wrong algorithm oid
|
||||
CMP_R_WRONG_PBM_VALUE:155:wrong pbm value
|
||||
CMS_R_ADD_SIGNER_ERROR:99:add signer error
|
||||
CMS_R_ATTRIBUTE_ERROR:161:attribute error
|
||||
CMS_R_CERTIFICATE_ALREADY_PRESENT:175:certificate already present
|
||||
@@ -2741,6 +2759,7 @@ PROV_R_BAD_TLS_CLIENT_VERSION:161:bad tls client version
|
||||
PROV_R_BN_ERROR:160:bn error
|
||||
PROV_R_BOTH_MODE_AND_MODE_INT:127:both mode and mode int
|
||||
PROV_R_CIPHER_OPERATION_FAILED:102:cipher operation failed
|
||||
PROV_R_FAILED_DURING_DERIVATION:164:failed during derivation
|
||||
PROV_R_FAILED_TO_DECRYPT:162:failed to decrypt
|
||||
PROV_R_FAILED_TO_GENERATE_KEY:121:failed to generate key
|
||||
PROV_R_FAILED_TO_GET_PARAMETER:103:failed to get parameter
|
||||
@@ -3359,6 +3378,7 @@ X509_R_BAD_X509_FILETYPE:100:bad x509 filetype
|
||||
X509_R_BASE64_DECODE_ERROR:118:base64 decode error
|
||||
X509_R_CANT_CHECK_DH_KEY:114:cant check dh key
|
||||
X509_R_CERT_ALREADY_IN_HASH_TABLE:101:cert already in hash table
|
||||
X509_R_CERTIFICATE_VERIFICATION_FAILED:139:certificate verification failed
|
||||
X509_R_CRL_ALREADY_DELTA:127:crl already delta
|
||||
X509_R_CRL_VERIFY_FAILURE:131:crl verify failure
|
||||
X509_R_IDP_MISMATCH:128:idp mismatch
|
||||
|
||||
Reference in New Issue
Block a user