Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assorted fixes #436

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 0 additions & 3 deletions apps/apps.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if !defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_SYS_WINCE) && !defined(NETWARE_CLIB)
# include <strings.h>
#endif
#ifndef NO_SYS_TYPES_H
# include <sys/types.h>
#endif
Expand Down
12 changes: 3 additions & 9 deletions apps/ca.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,24 +98,18 @@
#undef BSIZE
#define BSIZE 256

#define BASE_SECTION "ca"
#define BASE_SECTION "ca"

#define ENV_DEFAULT_CA "default_ca"

#define STRING_MASK "string_mask"
#define STRING_MASK "string_mask"
#define UTF8_IN "utf8"

#define ENV_DIR "dir"
#define ENV_CERTS "certs"
#define ENV_CRL_DIR "crl_dir"
#define ENV_CA_DB "CA_DB"
#define ENV_NEW_CERTS_DIR "new_certs_dir"
#define ENV_CERTIFICATE "certificate"
#define ENV_CERTIFICATE "certificate"
#define ENV_SERIAL "serial"
#define ENV_CRLNUMBER "crlnumber"
#define ENV_CRL "crl"
#define ENV_PRIVATE_KEY "private_key"
#define ENV_RANDFILE "RANDFILE"
#define ENV_DEFAULT_DAYS "default_days"
#define ENV_DEFAULT_STARTDATE "default_startdate"
#define ENV_DEFAULT_ENDDATE "default_enddate"
Expand Down
2 changes: 0 additions & 2 deletions apps/ecparam.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,6 @@ int ecparam_main(int argc, char **argv)
}

if (check) {
if (group == NULL)
BIO_printf(bio_err, "no elliptic curve parameters\n");
BIO_printf(bio_err, "checking elliptic curve parameters: ");
if (!EC_GROUP_check(group, NULL)) {
BIO_printf(bio_err, "failed\n");
Expand Down
5 changes: 0 additions & 5 deletions apps/engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,12 @@ static void identity(char *ptr)

static int append_buf(char **buf, const char *s, int *size, int step)
{
int l = strlen(s);

if (*buf == NULL) {
*size = step;
*buf = app_malloc(*size, "engine buffer");
**buf = '\0';
}

if (**buf != '\0')
l += 2; /* ", " */

if (strlen(*buf) + strlen(s) >= (unsigned int)*size) {
*size += step;
*buf = OPENSSL_realloc(*buf, *size);
Expand Down
2 changes: 0 additions & 2 deletions apps/gendsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@
# include <openssl/x509.h>
# include <openssl/pem.h>

# define DEFBITS 512

typedef enum OPTION_choice {
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
OPT_OUT, OPT_PASSOUT, OPT_ENGINE, OPT_RAND, OPT_CIPHER
Expand Down
2 changes: 1 addition & 1 deletion apps/ocsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,7 @@ static OCSP_RESPONSE *query_responder(BIO *cbio, const char *host,
return NULL;
}

if (BIO_get_fd(cbio, &fd) <= 0) {
if (BIO_get_fd(cbio, &fd) < 0) {
BIO_puts(bio_err, "Can't get connection fd\n");
goto err;
}
Expand Down
2 changes: 1 addition & 1 deletion crypto/aes/asm/aesni-x86.pl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
$inout4="xmm6"; $in0="xmm6";
$inout5="xmm7"; $ivec="xmm7";

# AESNI extenstion
# AESNI extension
sub aeskeygenassist
{ my($dst,$src,$imm)=@_;
if ("$dst:$src" =~ /xmm([0-7]):xmm([0-7])/)
Expand Down
1 change: 0 additions & 1 deletion crypto/bio/b_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ int BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u),
if ((rows * dump_width) < len)
rows++;
for (i = 0; i < rows; i++) {
buf[0] = '\0'; /* start with empty string */
BUF_strlcpy(buf, str, sizeof buf);
BIO_snprintf(tmp, sizeof tmp, "%04x - ", i * dump_width);
BUF_strlcat(buf, tmp, sizeof buf);
Expand Down
2 changes: 1 addition & 1 deletion crypto/bn/asm/ia64.S
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ bn_mul_add_words:

// This loop spins in 3*(n+10) ticks on Itanium and in 2*(n+10) on
// Itanium 2. Yes, unlike previous versions it scales:-) Previous
// version was peforming *all* additions in IALU and was starving
// version was performing *all* additions in IALU and was starving
// for those even on Itanium 2. In this version one addition is
// moved to FPU and is folded with multiplication. This is at cost
// of propogating the result from previous call to this subroutine
Expand Down
2 changes: 1 addition & 1 deletion crypto/bn/bn_gf2m.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[],
bn_check_top(a);
BN_CTX_start(ctx);
if ((s = BN_CTX_get(ctx)) == NULL)
return 0;
goto err;
if (!bn_wexpand(s, 2 * a->top))
goto err;

Expand Down
4 changes: 3 additions & 1 deletion crypto/bn/bn_recp.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,10 @@ int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,

if (BN_ucmp(m, &(recp->N)) < 0) {
BN_zero(d);
if (!BN_copy(r, m))
if (!BN_copy(r, m)) {
BN_CTX_end(ctx);
return 0;
}
BN_CTX_end(ctx);
return (1);
}
Expand Down
7 changes: 5 additions & 2 deletions crypto/bn/bn_x931p.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,14 @@ int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx)
* exceeded.
*/
if (!BN_rand(Xp, nbits, 1, 0))
return 0;
goto err;

BN_CTX_start(ctx);
t = BN_CTX_get(ctx);

for (i = 0; i < 1000; i++) {
if (!BN_rand(Xq, nbits, 1, 0))
return 0;
goto err;
/* Check that |Xp - Xq| > 2^(nbits - 100) */
BN_sub(t, Xp, Xq);
if (BN_num_bits(t) > (nbits - 100))
Expand All @@ -235,6 +235,9 @@ int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx)

return 0;

err:
BN_CTX_end(ctx);
return 0;
}

/*
Expand Down
3 changes: 1 addition & 2 deletions crypto/conf/conf_def.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,11 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
goto err;
}

section = OPENSSL_malloc(10);
section = BUF_strdup("default");
if (section == NULL) {
CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
goto err;
}
BUF_strlcpy(section, "default", 10);

if (_CONF_new_data(conf) == 0) {
CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
Expand Down
18 changes: 5 additions & 13 deletions crypto/dsa/dsa_gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,8 @@ int DSA_generate_parameters_ex(DSA *ret, int bits,
return ret->meth->dsa_paramgen(ret, bits, seed_in, seed_len,
counter_ret, h_ret, cb);
else {
const EVP_MD *evpmd;
size_t qbits = bits >= 2048 ? 256 : 160;

if (bits >= 2048) {
qbits = 256;
evpmd = EVP_sha256();
} else {
qbits = 160;
evpmd = EVP_sha1();
}
const EVP_MD *evpmd = bits >= 2048 ? EVP_sha256() : EVP_sha1();
size_t qbits = EVP_MD_size(evpmd) * 8;

return dsa_builtin_paramgen(ret, bits, qbits, evpmd,
seed_in, seed_len, NULL, counter_ret,
Expand Down Expand Up @@ -142,14 +134,14 @@ int dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits,
memcpy(seed, seed_in, seed_len);
}

if ((mont = BN_MONT_CTX_new()) == NULL)
goto err;

if ((ctx = BN_CTX_new()) == NULL)
goto err;

BN_CTX_start(ctx);

if ((mont = BN_MONT_CTX_new()) == NULL)
goto err;

r0 = BN_CTX_get(ctx);
g = BN_CTX_get(ctx);
W = BN_CTX_get(ctx);
Expand Down
2 changes: 0 additions & 2 deletions crypto/evp/e_aes_cbc_hmac_sha256.c
Original file line number Diff line number Diff line change
Expand Up @@ -820,8 +820,6 @@ static int aesni_cbc_hmac_sha256_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg,
if (arg != EVP_AEAD_TLS1_AAD_LEN)
return -1;

len = p[arg - 2] << 8 | p[arg - 1];

if (ctx->encrypt) {
key->payload_length = len;
if ((key->aux.tls_ver =
Expand Down
69 changes: 0 additions & 69 deletions crypto/evp/e_dsa.c

This file was deleted.

4 changes: 2 additions & 2 deletions crypto/evp/evp_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md,
EVP_MD_CTX_init(&c);
for (;;) {
if (!EVP_DigestInit_ex(&c, md, NULL))
return 0;
goto err;
if (addmd++)
if (!EVP_DigestUpdate(&c, &(md_buf[0]), mds))
goto err;
Expand Down Expand Up @@ -188,6 +188,6 @@ int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md,
rv = type->key_len;
err:
EVP_MD_CTX_cleanup(&c);
OPENSSL_cleanse(&(md_buf[0]), EVP_MAX_MD_SIZE);
OPENSSL_cleanse(md_buf, sizeof(md_buf));
return rv;
}
15 changes: 11 additions & 4 deletions crypto/evp/evp_pbe.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,15 @@ int EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid,
{
EVP_PBE_CTL *pbe_tmp;

if (pbe_algs == NULL)
if (pbe_algs == NULL) {
pbe_algs = sk_EVP_PBE_CTL_new(pbe_cmp);
if ((pbe_tmp = OPENSSL_malloc(sizeof(*pbe_tmp))) == NULL) {
EVPerr(EVP_F_EVP_PBE_ALG_ADD_TYPE, ERR_R_MALLOC_FAILURE);
return 0;
if (pbe_algs == NULL)
goto err;
}

if ((pbe_tmp = OPENSSL_malloc(sizeof(*pbe_tmp))) == NULL)
goto err;

pbe_tmp->pbe_type = pbe_type;
pbe_tmp->pbe_nid = pbe_nid;
pbe_tmp->cipher_nid = cipher_nid;
Expand All @@ -223,6 +226,10 @@ int EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid,

sk_EVP_PBE_CTL_push(pbe_algs, pbe_tmp);
return 1;

err:
EVPerr(EVP_F_EVP_PBE_ALG_ADD_TYPE, ERR_R_MALLOC_FAILURE);
return 0;
}

int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,
Expand Down
9 changes: 7 additions & 2 deletions crypto/hmac/hm_ameth.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,14 @@ static int old_hmac_decode(EVP_PKEY *pkey,
ASN1_OCTET_STRING *os;
os = ASN1_OCTET_STRING_new();
if (!os || !ASN1_OCTET_STRING_set(os, *pder, derlen))
return 0;
EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, os);
goto err;
if (!EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, os))
goto err;
return 1;

err:
ASN1_OCTET_STRING_free(os);
return 0;
}

static int old_hmac_encode(const EVP_PKEY *pkey, unsigned char **pder)
Expand Down
6 changes: 0 additions & 6 deletions crypto/ocsp/ocsp_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,6 @@ int OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath,
if ((p = strchr(p, ':'))) {
*p = 0;
port = p + 1;
} else {
/* Not found: set default port */
if (*pssl)
port = "443";
else
port = "80";
}

*pport = BUF_strdup(port);
Expand Down
1 change: 0 additions & 1 deletion crypto/ocsp/ocsp_prn.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE *o, unsigned long flags)
return 1;
}

i = ASN1_STRING_length(rb->response);
if ((br = OCSP_response_get1_basic(o)) == NULL)
goto err;
rd = &br->tbsResponseData;
Expand Down