diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2009-04-15 15:27:03 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2009-04-15 15:27:03 +0000 |
commit | e5fa864f62c096536d700d977a5eb924ad293304 (patch) | |
tree | f97991450654a74c8f8ace4ea11e88a1c055818f /crypto | |
parent | 22c98d4aad76f39ab19e5b63e1448c7d28ca7617 (diff) |
Updates from 1.0.0-stable.
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/bio/bio.h | 1 | ||||
-rw-r--r-- | crypto/bio/bss_dgram.c | 55 | ||||
-rw-r--r-- | crypto/dsa/dsa_asn1.c | 9 | ||||
-rw-r--r-- | crypto/evp/evp.h | 1 | ||||
-rw-r--r-- | crypto/evp/evp_lib.c | 5 | ||||
-rw-r--r-- | crypto/evp/names.c | 4 | ||||
-rw-r--r-- | crypto/x509/x509_vfy.c | 2 | ||||
-rw-r--r-- | crypto/x509v3/v3_cpols.c | 1 |
8 files changed, 72 insertions, 6 deletions
diff --git a/crypto/bio/bio.h b/crypto/bio/bio.h index ea5323d20f..3371342fc1 100644 --- a/crypto/bio/bio.h +++ b/crypto/bio/bio.h @@ -159,6 +159,7 @@ extern "C" { #define BIO_CTRL_DGRAM_SET_PEER 44 /* Destination for the data */ +#define BIO_CTRL_DGRAM_SET_TIMEOUT 45 /* modifiers */ #define BIO_FP_READ 0x02 diff --git a/crypto/bio/bss_dgram.c b/crypto/bio/bss_dgram.c index c3da6dc82f..dde0abe05a 100644 --- a/crypto/bio/bss_dgram.c +++ b/crypto/bio/bss_dgram.c @@ -66,6 +66,10 @@ #include <openssl/bio.h> +#ifdef OPENSSL_SYS_WIN32 +#include <sys/timeb.h> +#endif + #define IP_MTU 14 /* linux is lame */ #ifdef WATT32 @@ -104,6 +108,8 @@ typedef struct bio_dgram_data_st unsigned int connected; unsigned int _errno; unsigned int mtu; + struct timeval hstimeoutdiff; + struct timeval hstimeout; } bio_dgram_data; BIO_METHOD *BIO_s_datagram(void) @@ -196,6 +202,30 @@ static int dgram_read(BIO *b, char *out, int outl) BIO_set_retry_read(b); data->_errno = get_last_socket_error(); } + memset(&(data->hstimeout), 0, sizeof(struct timeval)); + } + else + { + if (data->hstimeout.tv_sec > 0 || data->hstimeout.tv_usec > 0) + { + struct timeval curtime; +#ifdef OPENSSL_SYS_WIN32 + struct _timeb tb; + _ftime(&tb); + curtime.tv_sec = (long)tb.time; + curtime.tv_usec = (long)tb.millitm * 1000; +#else + gettimeofday(&curtime, NULL); +#endif + + if (curtime.tv_sec >= data->hstimeout.tv_sec && + curtime.tv_usec >= data->hstimeout.tv_usec) + { + data->_errno = EAGAIN; + ret = -1; + memset(&(data->hstimeout), 0, sizeof(struct timeval)); + } + } } } return(ret); @@ -345,6 +375,30 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr) memcpy(&(data->peer), to, sizeof(struct sockaddr)); break; + case BIO_CTRL_DGRAM_SET_TIMEOUT: + if (num > 0) + { +#ifdef OPENSSL_SYS_WIN32 + struct _timeb tb; + _ftime(&tb); + data->hstimeout.tv_sec = (long)tb.time; + data->hstimeout.tv_usec = (long)tb.millitm * 1000; +#else + gettimeofday(&(data->hstimeout), NULL); +#endif + data->hstimeout.tv_sec += data->hstimeoutdiff.tv_sec; + data->hstimeout.tv_usec += data->hstimeoutdiff.tv_usec; + if (data->hstimeout.tv_usec >= 1000000) + { + data->hstimeout.tv_sec++; + data->hstimeout.tv_usec -= 1000000; + } + } + else + { + memset(&(data->hstimeout), 0, sizeof(struct timeval)); + } + break; #if defined(SO_RCVTIMEO) case BIO_CTRL_DGRAM_SET_RECV_TIMEOUT: #ifdef OPENSSL_SYS_WINDOWS @@ -360,6 +414,7 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr) sizeof(struct timeval)) < 0) { perror("setsockopt"); ret = -1; } #endif + memcpy(&(data->hstimeoutdiff), ptr, sizeof(struct timeval)); break; case BIO_CTRL_DGRAM_GET_RECV_TIMEOUT: #ifdef OPENSSL_SYS_WINDOWS diff --git a/crypto/dsa/dsa_asn1.c b/crypto/dsa/dsa_asn1.c index 084bd451c6..8277a74be2 100644 --- a/crypto/dsa/dsa_asn1.c +++ b/crypto/dsa/dsa_asn1.c @@ -69,12 +69,15 @@ static int sig_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, if(operation == ASN1_OP_NEW_PRE) { DSA_SIG *sig; sig = OPENSSL_malloc(sizeof(DSA_SIG)); + if (!sig) + { + DSAerr(DSA_F_SIG_CB, ERR_R_MALLOC_FAILURE); + return 0; + } sig->r = NULL; sig->s = NULL; *pval = (ASN1_VALUE *)sig; - if(sig) return 2; - DSAerr(DSA_F_SIG_CB, ERR_R_MALLOC_FAILURE); - return 0; + return 2; } return 1; } diff --git a/crypto/evp/evp.h b/crypto/evp/evp.h index a73f7434b8..4eecdbeea7 100644 --- a/crypto/evp/evp.h +++ b/crypto/evp/evp.h @@ -421,6 +421,7 @@ int EVP_MD_type(const EVP_MD *md); int EVP_MD_pkey_type(const EVP_MD *md); int EVP_MD_size(const EVP_MD *md); int EVP_MD_block_size(const EVP_MD *md); +unsigned long EVP_MD_flags(const EVP_MD *md); const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx); #define EVP_MD_CTX_size(e) EVP_MD_size(EVP_MD_CTX_md(e)) diff --git a/crypto/evp/evp_lib.c b/crypto/evp/evp_lib.c index d815bc6d6f..b92a6626fa 100644 --- a/crypto/evp/evp_lib.c +++ b/crypto/evp/evp_lib.c @@ -263,6 +263,11 @@ int EVP_MD_size(const EVP_MD *md) return md->md_size; } +unsigned long EVP_MD_flags(const EVP_MD *md) + { + return md->flags; + } + const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx) { if (!ctx) diff --git a/crypto/evp/names.c b/crypto/evp/names.c index feaf80dfe8..7e4d742a66 100644 --- a/crypto/evp/names.c +++ b/crypto/evp/names.c @@ -145,7 +145,7 @@ static void do_all_cipher_fn(const OBJ_NAME *nm, void *arg) if (nm->alias) dc->fn(NULL, nm->name, nm->data, dc->arg); else - dc->fn((const EVP_CIPHER *)nm->data, NULL, NULL, dc->arg); + dc->fn((const EVP_CIPHER *)nm->data, nm->name, NULL, dc->arg); } void EVP_CIPHER_do_all(void (*fn)(const EVP_CIPHER *ciph, @@ -179,7 +179,7 @@ static void do_all_md_fn(const OBJ_NAME *nm, void *arg) if (nm->alias) dc->fn(NULL, nm->name, nm->data, dc->arg); else - dc->fn((const EVP_MD *)nm->data, NULL, NULL, dc->arg); + dc->fn((const EVP_MD *)nm->data, nm->name, NULL, dc->arg); } void EVP_MD_do_all(void (*fn)(const EVP_MD *md, diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c index f662124d76..9ff66cff13 100644 --- a/crypto/x509/x509_vfy.c +++ b/crypto/x509/x509_vfy.c @@ -1124,7 +1124,7 @@ static int check_crl_path(X509_STORE_CTX *ctx, X509 *x) /* Verify CRL issuer */ ret = X509_verify_cert(&crl_ctx); - if (!ret) + if (ret <= 0) goto err; /* Check chain is acceptable */ diff --git a/crypto/x509v3/v3_cpols.c b/crypto/x509v3/v3_cpols.c index b452ac4e53..1f0798b946 100644 --- a/crypto/x509v3/v3_cpols.c +++ b/crypto/x509v3/v3_cpols.c @@ -453,4 +453,5 @@ void X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent) IMPLEMENT_STACK_OF(X509_POLICY_NODE) +IMPLEMENT_STACK_OF(X509_POLICY_DATA) |